I want to get data from cloud foundry using curl, but I'm not able to authenticate (oauth against CF). Please, could someone point me to and example how to get oauth token? I want to use login name and password.
Thanks
To get a token for a Server Application client, make a POST request to the Panopto Oauth2 token endpoint. The post request should be sent with a content type of x-www-form-urlencoded, and include the following parameters: grant_type: The method you are using to get a token.
You use the POST operation on the api/get_token element to request your unique token that is required to authenticate the REST API requests. , and click Profile. Then, click Show token.
Try this. I found it in the Cloud Foundry docs: https://github.com/cloudfoundry/uaa/blob/master/docs/UAA-APIs.rst#oauth2-token-endpoint
curl -v -XPOST -H"Application/json" -u "cf:" --data "username=<username>&password=<password>&client_id=cf&grant_type=password&response_type=token" https://login.run.pivotal.io/oauth/token
If you have already logged in using cf
, you will find that the authorization token is stored in ~/.cf/config.json under they key "AccessToken". You can easily pull it out of there.
If you need to get the Authorization bearer token yourself without using the cf
CLI you can follow the instructions at https://www.ng.bluemix.net/docs/#services/AppUserRegistry/index.html#appuserregistry . You can also export CF_TRACE=true
and then do a cf login
yourself and watch the REST dance the CLI does with the server to get the authorization token.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With