I cannot authorize my account

1,800 views
Skip to first unread message

Reem Kurdi

unread,
Sep 20, 2020, 2:37:46 PM9/20/20
to ORCID API Users
Hello, 

I hope you are doing well. 

I have created and registered an account with ORCID API. 

According to the links below, I need to first authorize my account and then request an access token to be able to read public research. 


Second step: Get access token to read public record 

I am really confused and I am not sure whether I am following the steps correctly. I have searched everywhere I can, but I need some additional help please. 

When I tried authorizing my ORCID id, I put the following:

https://sandbox.orcid.org/oauth/authorize? client_id=[Your client ID]& response_type=code&scope=/authenticate& redirect_uri=[Your landing page] 

I replaced the bold with my details. When it comes to authenticate, what should we put there? 

Moreover, when I tried obtaining a token I got this message as my account is still not authorized yet: 401 Unauthorized

{
  "error": "unauthorized",
  "error_description": "An Authentication object was not found in the SecurityContext"
}

Can someone please help me? I highly appreciate your time and effort. 

Thank you in advance. 

Best regards, 

Reem Kurdi

Christian Gawron

unread,
Sep 20, 2020, 3:25:24 PM9/20/20
to Reem Kurdi, ORCID API Users
Deer Reem,

ORCiD  uses the openid connect protocol. One easy way to test the authentication flow is by using https://openidconnect.net/.

https://sandbox.orcid.org/oauth/authorize? client_id=[Your client ID]& response_type=code&scope=/authenticate& redirect_uri=[Your landing page] 

I replaced the bold with my details. When it comes to authenticate, what should we put there? 
scope is the openid connect scope, e.g. "openid", "profile" or a combination (see https://auth0.com/docs/scopes/openid-connect-scopes).
 
Moreover, when I tried obtaining a token I got this message as my account is still not authorized yet: 401 Unauthorized

{
  "error": "unauthorized",
  "error_description": "An Authentication object was not found in the SecurityContext"
}
The code will be handed over to the redirect URL you have provided. In the normal openid connect flow (with response type code), you have to exchange the code with the authentication token. This authentication token has to be used in a "Authentication: Bearer" header to authenticate subsequent calls to the ORCiD API.

I would strongly recommend to use a proven openid connect client library instead of implementing your own.

Best wishes
Christian 

Reem Kurdi

unread,
Sep 21, 2020, 5:29:10 AM9/21/20
to ORCID API Users
Hello, 

Many thanks for your helpful reply!

I have followed what you told me to do and I was able to authorize my account. However, when I came to exchange my authorization code for tokens, I received this message:

{
  "error_description": "Malformed auth code.",
  "error": "invalid_grant"
}  

After authorizing my ORCID, I was redirected to https://developers.google.com/oauthplayground/?code=xxxxx where I pressed exchange authorization code for tokens and the above message was displayed. 

Kindly find a screenshot below of the page I was in. 

Here is the series of steps I am trying to follow: "Exchange authorization code" https://github.com/ORCID/ORCID-Source/blob/0b9b11ffde6cfd1645b77dd803f20ee36f1b7a8b/orcid-api-web/tutorial/get_id.md

This is an example response of what I should be receiving, but have not received unfortunately:

HTTP/1.1 200 OK ... {"access_token":"89f0181c-168b-4d7d-831c-1fdda2d7bbbb","token_type":"bearer", "refresh_token":"69e883f6-d84e-4ae6-87f5-ef0044e3e9a7","expires_in":631138518, "scope":"/authenticate","orcid":"0000-0001-2345-6789","name":"Sofia Garcia "}  

May you please tell me what am I missing?

Thank you so much in advance. 

Best, 

Reem Kurdi
auth.PNG

Christian Gawron

unread,
Sep 21, 2020, 8:42:39 AM9/21/20
to Reem Kurdi, ORCID API Users
Hi Reem,

I can't really say whether ORCiD should work with OAuth 2.0 Playground, but it definitely works with openidconnect.net:
orcid_oidc.gif



I have followed what you told me to do and I was able to authorize my account. However, when I came to exchange my authorization code for tokens, I received this message:

{
  "error_description": "Malformed auth code.",
  "error": "invalid_grant"
}  

Without a concise error description (which request with what parameters returns this error message?) it's hard to help you.

I advise that you try the authentication with openidconnect.net. If that works, you should be able to use one of the many oidc client libraries available for many purposes and languages.
 
Best wishes
Christian

--
You received this message because you are subscribed to the Google Groups "ORCID API Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orcid-api-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/orcid-api-users/bd41a070-07b3-429e-a25f-81da2172598dn%40googlegroups.com.

Reem Kurdi

unread,
Sep 22, 2020, 5:48:40 AM9/22/20
to ORCID API Users
Hello, 

Many thanks for your helpful reply once again. 

I was able to use openid connect and I have authorized and obtained an id/access token using it. 

Kindly find the image below attached showing that it has been successful. 

Now, what I plan to do is retrieve public researcher information from ORCID. How is that possible using openid connect? 

For example, when using postman I want to be able to do the following:

Public API
URL https://pub.sandbox.orcid.org/[version]/[ORCID iD]/[endpoint]
Method GET
Header Content-Type: application/vnd.orcid+xml OR Content-Type: application/orcid+json
Header Authorization: Bearer [Your access token]  

Have you tried retrieving public researcher information before? If yes, may you please tell me what you have done. 

Thank you so much in advance. Apologies for any inconveniences I may have caused. 

Best regards, 

Reem Kurdi

validd.PNG

Pedro Costa

unread,
Sep 22, 2020, 10:01:56 AM9/22/20
to ORCID API Users
Hi Reem,

If all you want to do is read publicly accessible data from researchers' records over the ORCID API, you will need to use the /read-public scope. This tutorial explains how to do it: https://github.com/ORCID/ORCID-Source/blob/master/orcid-api-web/tutorial/read_public.md


I'd recommend you try completing the workflow described in the read_public tutorial. Just let me know if you have questions!

Pedro Costa
QA & Support Specialist
Reply all
Reply to author
Forward
0 new messages