Hello team,
I am trying to integrate orcId public apis for getting user's profile
I have followed following steps :
1) I am hitting auth url :
2) User is prompted with a page where he enters his credentials and authorizes to share the details. Then i am trying to create token by below code
PFB java code for post request for getting token
String code=request.getParameter("code");
HttpClient httpClient = new HttpClient();
postRequest.addParameter("scope", "/read-public");
postRequest.addParameter("grant_type", "authorization_code");
postRequest.addParameter("code", code);
postRequest.addParameter("redirect_uri", callbackURl);
postRequest.addParameter("client_id", linkedinKey);
postRequest.addParameter("client_secret",linkedinSecret);
httpClient.executeMethod(postRequest);
accessTokenJson = postRequest.getResponseBodyAsString();
token response for above request is
{"access_token":"608fcba2-b74e-47cc-a17c-c236371b4c24","token_type":"bearer","refresh_token":"9198163c-08a9-4669-8ffe-c5b50b9a5997","expires_in":631138518,"scope":"/authenticate","name":"Musa Sanderwale","orcid":"0000-0001-9622-0750"}
In the response that I am receiving, scope is getting modified to /authenticate however I had sent it /read-public in request url.
Now using the orcid i am trying to access user_profile by hitting get url
GetMethod httpGet=new GetMethod(profileUrl);
httpGet.addRequestHeader("Accept", "application/json");
httpGet.addRequestHeader("Connection", "Keep-Alive");
httpGet.addRequestHeader("Authorization", "Bearer "+accessToken);
httpClient.executeMethod(httpGet);
result = httpGet.getResponseBodyAsString();
here i am getting below error
Response: {"message-version":"1.2","orcid-profile":null,"orcid-search-results":null,"error-desc":{"value":"Security problem : Insufficient or wrong scope [/authenticate]"}}
Please advise on how to get the public profile of an user using orcid Public API.