ropensci-archive / rorcid

:warning: ARCHIVED :warning: A programmatic interface the Orcid.org API
Other
109 stars 13 forks source link

Command line authentication #55

Closed pkraker closed 6 years ago

pkraker commented 6 years ago

OS: Ubuntu 14.04 R version: 3.4.0 Pacakge version: 0.4.2.9110

I am trying to run a script using rorcid with Rscript. I completed the following steps, but I always get the following error: Error: Unauthorized (HTTP 401)

  1. I registered an application with ORCiD with the redirect URL set to http://localhost
  2. I entered the client secret to my .Renviron-file by setting the variable ORCID_TOKEN

Where did I go wrong?

sckott commented 6 years ago

Sorry about the error. We've added docs on authentication here https://github.com/ropensci/rorcid/blob/master/R/auth.R#L11-L37

Can you run R interactively, and run orcid_auth(), then get the token out of that? Or does running `orcid_auth() not work when in R interactive session?

pkraker commented 6 years ago

Thanks, running orcid_auth() did indeed do the trick! But I had to switch to a system that allows for an interactive session to obtain the token. In the terminal-only environment, orcid_auth() produced the following error:

> orcid_auth()
no ORCID token found; attempting OAuth authentication

Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
/usr/bin/xdg-open: line 461: links2: command not found
/usr/bin/xdg-open: line 461: links: command not found
/usr/bin/xdg-open: line 461: lynx: command not found
/usr/bin/xdg-open: line 461: w3m: command not found
xdg-open: no method available for opening 'https://orcid.org/oauth/authorize?client_id=[...]
sckott commented 6 years ago

thanks for this, yeah we need to fail nicely when the user is in a context where a browser can no be opened

sckott commented 6 years ago

so i guess there's no way to open a browser in shell only env, so it can't work in that case. my smarter colleague tells me there's not really a way around this. So I guess we can at least document the pitfall