Closed JDLeongomez closed 4 years ago
thanks for the issue. I think I need to improve the docs on this a bit, so that's my fault.
Under what name did you save your token in the .Renviron
file? It should be a line that looks like
ORCID_TOKEN=a09a89sd0a9sfds-asf89a89sdf-asdfiasdf-asdf789asdf
Thanks for your answer. I have it stored exactly like in your example (I changed the actual code for xxxx).
ORCID_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx
I even tried putting the code within quotation marks (both single and double), but I still get the same Error: Unauthorized (HTTP 401)
every time.
Not sure if it helps, but when I use orcid_auth()
I get this, even if I use reauth = TRUE
:
[1] "Bearer xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
Also, in my case, and in the example you put for the orcid_auth()
funcion Documentation, the code is copompsed by a serires of 9-4-4-4-11 characters, but in your example above, is different. Not sure if that means anything?
the code is copompsed by a serires of 9-4-4-4-11 characters, but in your example above, is different
nah, the example above I just typed out quickly to have an example. not important
That "Bearer XXX" is what you should get from orcid_auth()
- as the header ORCID expects is Authorization: Bearer XXX
. We call orcid_auth()
internally as well, so we use that exact string for the authorization header
Can you do curl requests on the command line on your machine? If so, try (using your actual token)
curl -v -H "Authorization: Bearer xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \
https://pub.orcid.org/v2.1/0000-0002-1642-628X/educations
If that gives you the same error, then your token is probably no good, and we can see about fixing that. If a different error let me know what it is.
Dear Scott, I am quite a newbie on this, so I'm not completely sure I followed your instructions correctly. When I did the curl request on the command line, I get this (I distorted my TOKEN):
Hope this is useful! I really appreciate all your help.
thanks, looks like you didn't include the URL. try instead to include all that stuff in one string like
curl -v -H 'Authorization: Bearer xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' https://pub.orcid.org/v2.1/0000-0002-1642-628X/educations
Oh, sorry about that. Yes, after including the URL, and everything in one string, I get no errors. I get all the info from whatever ORCID user ID I enter. But the same Error: Unauthorized (HTTP 401)
when I work from R using rorcid
, though....
glad it worked on the command line at least. Now we know your token is good. But something in rorcid is going haywire. lets try this, set the token in the R session like:
Sys.setenv(ORCID_TOKEN = "your token")
library(rorcid)
# run some orcid fxn to see if it works
if that works, then maybe your R isn't picking up your .Renviron file
No Scott... no luck. I still get the same Error: Unauthorized (HTTP 401)
with every function I try.
The only difference, was that when using
as.orcid("0000-0002-1642-628X", verbose = TRUE)
I got a lot of info, including this:
WWW-Authenticate: Bearer realm="ORCID T1 API", error="invalid_token", error_description="Invalid access token: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"`
(But obviously with my actual token instead of xxxx). Here's a screen caption (once again, I blurred my actual token):
At the end it is followed by the same Error: Unauthorized (HTTP 401)
. I guess this should mean the token is wrong? However I'm not sure why it does work from on the command line but not from R.
Thanks for your amazing patience. I really appreciate all your help.
The reason your command did not work is that on Windows you have to use double quotes to create strings when running shell commands.
Can you show a screenshot of the successful request?
@JDLeongomez ^^
closing, no response
I found my Orcid Token interactively using
orcid_auth()
, and then saved it in my.Renviron
file. Now, if I enterorcid_auth()
I see my token. However, with any function I try to use, includingrorcid::orcid_educations()
,orcid(query = "ANY NAME")
, orrorcid::orcid_employments()
, I always get the same error:Session Info
```r - Session info -------------------------------------------------------------------------------------------------- setting value version R version 3.5.3 (2019-03-11) os Windows >= 8 x64 system x86_64, mingw32 ui RStudio language (EN) collate Spanish_Colombia.1252 ctype Spanish_Colombia.1252 tz America/Bogota date 2019-04-28 - Packages ------------------------------------------------------------------------------------------------------ package * version date lib source assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.5.3) backports 1.1.4 2019-04-10 [1] CRAN (R 3.5.3) callr 3.2.0 2019-03-15 [1] CRAN (R 3.5.3) cli 1.1.0 2019-03-19 [1] CRAN (R 3.5.3) crayon 1.3.4 2017-09-16 [1] CRAN (R 3.5.0) crul 0.7.4 2019-03-28 [1] CRAN (R 3.5.3) curl 3.3 2019-01-10 [1] CRAN (R 3.5.2) desc 1.2.0 2018-05-01 [1] CRAN (R 3.5.1) devtools 2.0.2 2019-04-08 [1] CRAN (R 3.5.3) digest 0.6.18 2018-10-10 [1] CRAN (R 3.5.1) dplyr 0.8.0.1 2019-02-15 [1] CRAN (R 3.5.2) fauxpas 0.2.0 2018-03-01 [1] CRAN (R 3.5.3) fs 1.2.7 2019-03-19 [1] CRAN (R 3.5.3) glue 1.3.1 2019-03-12 [1] CRAN (R 3.5.3) httpcode 0.2.0 2016-11-14 [1] CRAN (R 3.5.2) httr 1.4.0 2018-12-11 [1] CRAN (R 3.5.2) jsonlite 1.6 2018-12-07 [1] CRAN (R 3.5.2) knitr 1.22 2019-03-08 [1] CRAN (R 3.5.3) magrittr 1.5 2014-11-22 [1] CRAN (R 3.5.0) memoise 1.1.0 2017-04-21 [1] CRAN (R 3.5.0) pillar 1.3.1 2018-12-15 [1] CRAN (R 3.5.2) pkgbuild 1.0.3 2019-03-20 [1] CRAN (R 3.5.3) pkgconfig 2.0.2 2018-08-16 [1] CRAN (R 3.5.1) pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.5.1) prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.5.1) processx 3.3.0 2019-03-10 [1] CRAN (R 3.5.3) ps 1.3.0 2018-12-21 [1] CRAN (R 3.5.2) purrr 0.3.2 2019-03-15 [1] CRAN (R 3.5.3) R6 2.4.0 2019-02-14 [1] CRAN (R 3.5.2) Rcpp 1.0.1 2019-03-17 [1] CRAN (R 3.5.3) remotes 2.0.4 2019-04-10 [1] CRAN (R 3.5.3) rlang 0.3.4 2019-04-07 [1] CRAN (R 3.5.3) rorcid * 0.4.3.9110 2019-04-23 [1] Github (ropensci/rorcid@0da5f38) rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.5.0) rstudioapi 0.10 2019-03-19 [1] CRAN (R 3.5.3) sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.5.2) testthat 2.1.0 2019-04-22 [1] CRAN (R 3.5.3) tibble 2.1.1 2019-03-16 [1] CRAN (R 3.5.3) tidyselect 0.2.5 2018-10-11 [1] CRAN (R 3.5.1) triebeard 0.3.0 2016-08-04 [1] CRAN (R 3.5.2) urltools 1.7.3 2019-04-14 [1] CRAN (R 3.5.3) usethis 1.5.0 2019-04-07 [1] CRAN (R 3.5.3) vitae * 0.1.0 2019-01-08 [1] CRAN (R 3.5.3) whisker 0.3-2 2013-04-28 [1] CRAN (R 3.5.0) withr 2.1.2 2018-03-15 [1] CRAN (R 3.5.0) xfun 0.6 2019-04-02 [1] CRAN (R 3.5.3) yaml 2.2.0 2018-07-25 [1] CRAN (R 3.5.1) [1] C:/Users/JuanDavid/Documents/R/win-library/3.5 [2] C:/Program Files/R/R-3.5.3/library> ```