Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting author information from orcid API #639

Open
c-martinez opened this issue Aug 18, 2022 · 12 comments
Open

Getting author information from orcid API #639

c-martinez opened this issue Aug 18, 2022 · 12 comments
Labels
feature-request New features or improvements. question Further information is requested

Comments

@c-martinez
Copy link

At the moment, given name and last name and orcid are manually entered. It would save the user some typing if, when an orcid is provided, it could auto-complete given name and last name. This information could be pulled from orcid using their public API (maybe email and affiliation can also be retrieved).

Is there any reason NOT to do this?

@recap recap added the feature-request New features or improvements. label Aug 19, 2022
@abelsiqueira
Copy link
Collaborator

abelsiqueira commented Aug 22, 2022

I don't see any reason to NOT do this.
Do you know the orcid API? Can you give a hand with that?

@recap
Copy link
Contributor

recap commented Aug 22, 2022

Just pulling the public-record.json (e.g. https://orcid.org/xxxx-xxxx-xxxx-xxxx/public-record.json) file of a user does not work client side cause of CORS.

@c-martinez
Copy link
Author

I've played with the API before, I think I can figure out how to do this.

@c-martinez
Copy link
Author

From the orcid API documentation, you need to generate a Client ID and secret, which you can use to generate a token:

curl --location --request POST 'https://sandbox.orcid.org/oauth/token' \
--header 'Accept: application/json' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=XXXXX' \
--data-urlencode 'client_secret=XXXX' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'redirect_uri=https://developers.google.com/oauthplayground' \
--data-urlencode 'scope=/read-public'

That yields a token, which is valid for 20 years or so (maybe we can do this only once even offline)

To get record information you can then use that token to call the /expanded-search endpoint:

curl --location --request GET 'https://pub.sandbox.orcid.org/v3.0/expanded-search/?q=orcid:0000-0001-8555-849X&rows=1' \
--header 'Content-type: application/vnd.orcid+json' \
--header 'Authorization: Bearer TOKEN'

Result looks something like this:

{
  "expanded-result" : [ {
    "orcid-id" : "0000-0001-8555-849X",
    "given-names" : "James",
    "family-names" : "Bond",
    "credit-name" : null,
    "other-name" : [ ],
    "email" : [ "james@mailinator.com" ],
    "institution-name" : [ ]
  } ],
  "num-found" : 1
}

@abelsiqueira
Copy link
Collaborator

I think the challenge that we discussed (@fdiblen and @recap, please clarify it this is not correct) is that we don't have a backend and therefore we can't store our TOKEN safely.

What if we ask the user for a TOKEN, and don't store it?
What if we ask ask the user to login, and using OAuth we get a TOKEN and don't store it?
Is any of this feasible?

@abelsiqueira abelsiqueira added the question Further information is requested label Aug 25, 2022
@fdiblen
Copy link
Member

fdiblen commented Aug 25, 2022

Yes, we will need to think about how to do this. Maybe having a backend will help but it will be out of scope until we fix high priority issues.

@c-martinez
Copy link
Author

Actually, I played with the API a bit more, and it turns out you can use the expanded-search endpoint without a TOKEN. So I don't think a backend is necessary at all.

@c-martinez
Copy link
Author

Here a PR with a first attempt -- much work needed before it is anything sensible, but it is a start.

@recap
Copy link
Contributor

recap commented Aug 25, 2022

@c-martinez Did you have success with the public api https://pub.orcid.org/v3.0/expanded-search/?q=orcid:.... Seems it is also blocked by CORS?

@recap
Copy link
Contributor

recap commented Aug 25, 2022

never mind. seems to work!

@abelsiqueira
Copy link
Collaborator

The POC by @c-martinez is here: main...c-martinez:cff-initializer-javascript:orcid-api

@recap
Copy link
Contributor

recap commented Aug 26, 2022

Part of the public object returned is an array of institution-name which is the union of education and employment so the first in the array is not necessarily the current person's affiliation. Emails array seems to be always empty. So it seems the only useful info we get is name and family name. Is it worth it to do an external api call for just name and surname?

@c-martinez c-martinez mentioned this issue Mar 27, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New features or improvements. question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants