Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get OAuth token from CloudFoundry

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

like image 417
Pat Avatar asked Jan 16 '15 13:01

Pat


People also ask

How can I get my OAuth token?

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.

How do I get authentication token for REST API?

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.


2 Answers

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
like image 70
Scott Green Avatar answered Sep 29 '22 20:09

Scott Green


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.

like image 40
esnible Avatar answered Sep 29 '22 22:09

esnible