Retrieve a CF API OAuth token from a Service Account
Diese Seite ist noch nicht in deiner Sprache verfügbar. Englische Seite aufrufen
With the following commands you can retrieve a Cloud Foundry API OAuth token via your service account credentials:
## Set the required variables:USERNAME="<service-account-username@some-cf-domain.cloud>"PASSWORD="<service-account-password>"
### You can find the <system domain> in the API URL.### For example the <system-domain> in https://api.system.01.cf.eu01.stackit.cloud is "system.01.cf.eu01.stackit.cloud":
curl 'https://login.<system-domain>/oauth/token' -i -X POST -H 'Content-Type: application/x-www-form-urlencoded' -d "client_id=cf&client_secret=&grant_type=password&username=$USERNAME&password=$PASSWORD&token_format=jwt&response_type=token"You will receive a response similar to this:
{ "access_token": "ey...prettylongstring...h4", "token_type": "bearer", "id_token": "ey...prettylongstring...--xQ", "refresh_token": "ey...prettylongstring...6TX0", "expires_in": 1199, "scope": "openid uaa.user cloud_controller.read password.write cloud_controller.write", "jti": "ff...shortstring...58"}You can then copy the access_token field from this response and use it in the authorization header for subsequent Cloud Foundry API calls:
-H "Authorization: bearer $access_token"