Getting the authorisation code programatically

99 views
Skip to first unread message

Mateusz Susik

unread,
Jan 18, 2023, 12:14:08 PM1/18/23
to ORCID API Users
Hi!

I'm the author of the python-orcid library. In the past I used a request such as below to get the authorisation code:

curl -X POST -H 'Accept: */*' -H 'Accept-Encoding: gzip, deflate' -H 'Connection: keep-alive' -H 'Content-Length: 138' -H 'Content-Type: application/json;charset=UTF-8' -H 'Host: <HOST>' -H 'Origin: <ORIGIN> -H 'User-Agent: python-requests/2.25.1' -d '{"userName": "<USERNAME>", "password": "<PASSWORD>", "approved": true, "persistentTokenEnabled": true, "redirectUrl": null}' https://sandbox.orcid.org/oauth/custom/login.json

The request unfortunately outputs a 400 without specyfying the reason for it. Could you tell me why the request is bad?

Few years ago I had a similar problem, and I remember that I required a CSRF token to avoid the 400 code. To do that I had been sending a GET request to: https://sandbox.orcid.org/oauth/authorize . Unfortunately the response does not contain the token anymore.

What would be the right way to get the authorisation code these days without a web-browser interaction?

Thanks,
Mateusz

Fran Alsina

unread,
Mar 28, 2023, 4:43:24 AM3/28/23
to ORCID API Users
Hi Mateusz,

Thank you for your message.

Please, find here the step-by-step instructions on how to do the 3-legged OAuth process, including how to exchange the authorization code for an access token: 


Bear in mind that our latest API version is version 3.0. Please, work with the latest supported version. Find here all the information about our API: 


I hope that this helps.

Best regards,
Reply all
Reply to author
Forward
0 new messages