How to use REST API to get a token?

766 views
Skip to first unread message

iamflying

unread,
Mar 1, 2015, 9:22:42 PM3/1/15
to vcap...@cloudfoundry.org
Hi all,

I am trying to learn Cloud Foundry Rest API by following the blog[1] and code[2], but failed on authentication with message.

{"code":10000,"description":"Unknown request","error_code":"CF-NotFound"}

The curl command I used is 
    curl -k -H 'AUTHORIZATION: Basic Y2Y6' -d "username=${USERNAME}&password=${PASSWORD}&grant_type=password" ${PAAS_HOST}/uaa/oauth/token

My cf deployment is 190 with self signed certificate. Anything wrong? 

Thanks.

[1] http://www.activestate.com/blog/2015/01/get-some-rest-delving-cloud-foundry-rest-api
[2] https://github.com/bcferrycoder/curl-push/blob/master/curl-push.sh

Josh Ghiloni

unread,
Mar 1, 2015, 9:35:22 PM3/1/15
to vcap...@cloudfoundry.org
What do you mean by "${PAAS_HOST}"? The UAA has its own hostname. The URL you probably want is "${UAA_HOST}/oauth/token", because the "/uaa" URI prefix is normally only added when running locally. 

--
You received this message because you are subscribed to the Google Groups "Cloud Foundry Developers" group.
To view this discussion on the web visit https://groups.google.com/a/cloudfoundry.org/d/msgid/vcap-dev/c523a5f5-2f87-436a-bfd3-70d1bcc2832b%40cloudfoundry.org.

To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+u...@cloudfoundry.org.

iamflying

unread,
Mar 1, 2015, 9:43:20 PM3/1/15
to vcap...@cloudfoundry.org
Thanks Josh.

I changed PAAS_HOST to uaa.xxxx.xip.io and remove uaa from url., i.e, https://uaa.xxxx.xip.io/oauth/token, then I can get the token returned.

Josh Ghiloni

unread,
Mar 1, 2015, 9:56:14 PM3/1/15
to vcap...@cloudfoundry.org
Awesome, glad you got it worked out.

Reply all
Reply to author
Forward
0 new messages