Page 1 of 1

Access tokens

Posted: Wed Sep 11, 2013 3:04 pm
by gw1976
Hi all,
Did anyone have any success generating the access token using the wget command:

wget --no-check-certificate --header='Authorization: Basic <base64_string>' --header='Content-Type: application/x-www-form-urlencoded' <https_access_token_url>

and

wget --no-check-certificate --header='Authorization: Basic <base64_string>' --header='Content-Type: application/x-www-form-urlencoded' <https_access_token_url?grant_type=client_credentials>

I keep on getting a 400 error.
I also read one of the posts and tried the httprequester add-on for firefox and get the following error:

POST <https_access_token_url?grant_type=client_credentials>
Authorization: Basic <base64_string>
Content-Type: text/xml


-- response --
400 Bad Request
Content-Type: application/xml

WWW-Authenticate: Basic

Content-Length: 91

Connection: keep-alive

<error><code>400</code><message>Required param : grant_type</message>
</error>

Has anyone had any success generating the access token? If you did, which method did you use?
Thanks for any replies!

Re: Access tokens

Posted: Thu Sep 12, 2013 9:13 am
by EPO / OPS Support
To get the access token we need to send a POST request with "grant_type=client_credentials" in its body and the "Content-Type" header set to "application/x-www-form-urlencoded". I have tried the following command and it works:

curl -H "Authorization: Basic QWYzMjBrUVdkb1VnUmxnNUNrN3NITU5PVFN2cHI0M0Y6NWtuanh1YldoblhkeG45eQ==" -H "Content-Type: application/x-www-form-urlencoded" -d "grant_type=client_credentials" -X POST https://ops.epo.org/3.1/auth/accesstoken

Kind regards,

OPS support

Re: Access tokens

Posted: Thu Sep 12, 2013 8:28 pm
by gw1976
Thanks for the reply! I got it to work for the wget command. I made a big mistake by adding "grant_type=client_credentials" to the url instead of the body.

Have a nice day!