Emanuel Huser
Emanuel Huser

Reputation: 178

Get valid cloud foundry oAuth token with post request

If I successfully logged in to cloud foundry with cf login I can get a valid token with cf oauth-token.

How can I get a valid token with a curl call or post request with username and password?

Thank you and best regards. Menu

Upvotes: 0

Views: 1291

Answers (2)

Emanuel Huser
Emanuel Huser

Reputation: 178

I found a solution. With the following curl call I get a valid token:

curl -X POST "yourloginserver/oauth/token" -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" -H "Cache-Control: no-cache" -H "Authorization: Basic Y2Y6" -d "grant_type=password" -d "username=my-user" -d "password=my-password" -m 30 -v

Upvotes: 0

Matthias Winzeler
Matthias Winzeler

Reputation: 951

You can use the following snippet:

 [email protected]
 cf_password=yourpassword

 curl -X POST 'https://login.lyra-836.appcloud.swisscom.com/oauth/token' \
 -d "grant_type=password&scope=&username=${cf_user}&password=${cf_password}" \
 --user cf:

Hint: You can inspect the HTTP requests of a CLI command by setting CF_TRACE=true, i.e. CF_TRACE=1 cf login.

Upvotes: 2

Related Questions