0

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

Emanuel Huser
  • 178
  • 1
  • 11

2 Answers2

2

You can use the following snippet:

 cf_user=youremail@example.com
 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.

0

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

Dan Higham
  • 3,974
  • 16
  • 15
Emanuel Huser
  • 178
  • 1
  • 11