muschellij2 / rscopus

Scopus Database API Interface to R
74 stars 16 forks source link

Always says HTTP specified is (without API key): #16

Closed omnxbeast closed 5 years ago

omnxbeast commented 5 years ago

Every time I try to run any query I get this error.

I have tried setting the API via the Renviron file, directly into the command with api_key = 'key', and with the function set_api_key and each time it gives the same error. The API Key works when I use in web browser but for some reason RScopus seems not to be feeding it. Can't figure it out

muschellij2 commented 5 years ago

I cannot diagnose your issue with the amount of information you provided. Please provide a MCVE: https://stackoverflow.com/help/mcve.

omnxbeast commented 5 years ago

To all - was not an RScopus issue. Was a VPN issue that was behaving weird with R vs. browser.

However, I have two questions, is there a way to grab the "affil_name" when I get a return in the console with the author_retrival function. The affiliation information ($content$author-retrieval-response[[1]]$affiliation-current$affiliation-name) I draw generally does not show the school and at a minimum is the different from what shows up in affil_name in the console. I can't find where the affil_name is stored anywhere when I save the return as a variable. Authors found: auth_name au_id affil_id affil_name 1 Blah X Blah 12441 1242 Blah University School of Medicine

Also, is there a way to identify when there is more than one author in Scopus for that name? For example, when I type the generic name Richard Smith into scopus website there are many results but the API only returns one it seems. I am running a loop over several author names and would like to exclude any situations where Scopus identifies > 1 profile. Is this possible? Thanks.

muschellij2 commented 5 years ago

Yes and no. Multiple author names, you need a loop. If you have their IDs, you can use complete_multi_author_info.

If you want to get all the records from a name, use get_complete_author_info:

res = get_complete_author_info(last_name = "Smith", first_name = "Richard")
xx = res$content$`search-results`$entry
list_of_dfs = gen_entries_to_df(xx)
list_of_dfs$df

Once again - please read my response and Please provide a MCVE: https://stackoverflow.com/help/mcve. This will be the last response I give if you do not provide any example code.

omnxbeast commented 5 years ago

Hi thanks for the help. Didn't have any question about code in this regard, so I do not know what MCVE I would have given, my apologies.

If I may, I would like to clarify: I am not trying to get data on multiple authors; rather, if there are multiple authors under a given name, may I exclude this this name?

If not, then I suppose you would recommend running the get_complete_author_info command and if the length of df > 1 then move to the next name in the search? Only asking if there is another way since this will double the amount of API calls I make per search.

Finally, I couldn't find the h-index in the author_retrieval command; I also searched the PDF of the RScopus document (https://cran.r-project.org/web/packages/rscopus/rscopus.pdf) and did not see it mentioned. Is it obtainable from your package? Thank you. I apologize again in that I have no code to share - no code is broken. Thanks

muschellij2 commented 5 years ago

Have you tried my code? From the way it's coded, you can get the list of all authors from a specific name, but not search multiple authors at the same time unless you get their author IDs.

To be clear: multiple authors in one call, yes it's doable but you need the au_id for each author, not their names. To get their au_id, yes you have to loop over names. So if you're going to hit the API that much, just get the author information/citations along with that if you want.

omnxbeast commented 5 years ago

I did try your code, it worked great thanks! Essentially, I am going to be looping over 10,000 authors. If there are multiple author entries in scopus under the same name, I just want to exclude that name entirely. I am not trying to include any of them, as I won't know which is which, etc. Thus I am asking if the most efficient way to handle this is to run the get_complete_author_info command--using the name of author of interest (all I have)--and if the length of that is greater than 1 (meaning more than 1 author with that name) then I loop to the next name on my list, having excluded extracting any information on the person who had other people with the same name.

Also if you know whether h-index can be obtained from the package that would great.

muschellij2 commented 5 years ago

Please see https://works.bepress.com/john_muschelli/7/ and the attached code.

That's all I can help you with currently.

https://www.patreon.com/muschellij2

John

On Tue, Jan 29, 2019 at 5:48 PM omnxbeast notifications@github.com wrote:

I did try your code, it worked great thanks! Essentially, I am going to be looping over 10,000 authors. If there are multiple authors with the same name, I just want to exclude that name entirely. I am not trying to include any of them, as I won't know which is which, etc. Thus I am asking if the most efficient way to handle this is to run the get_complete_author_info command--using the name of author of interest (all I have)--and if the length of that is greater than 1 (meaning more than 1 author with that name) then I loop to the next name on my list, having excluded extracting any information on the person who had other people with the same name.

Also if you know whether h-index can be obtained from the package that would great.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/muschellij2/rscopus/issues/16#issuecomment-458738771, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBnruxNa2pLuxQ4jO2nvFUaKJnXDZwgks5vIM_FgaJpZM4aN7Uu .

omnxbeast commented 5 years ago

Thank you very much. This is a terrific package. Appreciate all the work you put into it.

omnxbeast commented 5 years ago

For anyone interested, here is how you would calculate h-index from the author_data() function with an output of jm (i.e. jm = author_data(last_name = "X", first_name "X"). This is from his paper (https://works.bepress.com/john_muschelli/7/) on the project he listed above--fantastic resource.

h_data = jm$df %>% mutate(citations = as.numeric(citedby-count)) %>% arrange(-citations) %>% mutate(n_papers = 1:n()) head(h_data[, c("short_title", "citations", "n_papers")])

h_index = max(which(h_data$citations >= h_data$n_papers)) cat(paste0("Calculated h-index is ", h_index)) Calculated h-index is Y

paddytobias commented 5 years ago

Hi,

I am also getting an error when trying to authenticate. I run this:

if (have_api_key()) {
    auth = elsevier_authenticate(api_key = api_key)
}

and I get the following:

$get_statement
Response [https://api.elsevier.com/authenticate?apiKey=####]
  Date: 2019-01-30 05:13
  Status: 403
  Content-Type: application/json;charset=UTF-8
  Size: 156 B

$content
$content$`service-error`
$content$`service-error`$status
$content$`service-error`$status$statusCode
[1] "AUTHENTICATION_ERROR"

$content$`service-error`$status$statusText
[1] "Requestor configuration settings insufficient for access to this resource."

I am saving my API key to the variableapi_key at the beginning.

Any assistance would be appreciated

omnxbeast commented 5 years ago

Hi,

I am also getting an error when trying to authenticate. I run this:

if (have_api_key()) {
    auth = elsevier_authenticate(api_key = api_key)
}

and I get the following:

$get_statement
Response [https://api.elsevier.com/authenticate?apiKey=####]
  Date: 2019-01-30 05:13
  Status: 403
  Content-Type: application/json;charset=UTF-8
  Size: 156 B

$content
$content$`service-error`
$content$`service-error`$status
$content$`service-error`$status$statusCode
[1] "AUTHENTICATION_ERROR"

$content$`service-error`$status$statusText
[1] "Requestor configuration settings insufficient for access to this resource."

I am saving my API key to the variableapi_key at the beginning.

Any assistance would be appreciated

Hi, I received the same error. Verify that you are on the network of the institution that provides your Scopus access. If you are not, you will get the same error. Use a VPN to access your institution's network and it may resolve the problem - it did for me.

rashi-goyal commented 5 years ago

Hi.. I am also facing authentication issues. Since I am located remotely, i have received an insttoken from Scopus to enable API access from outside the institute's network. But I am not able to use it correctly. As per Scopus, I have to "send it in addition to APIKey, with every request and set it as the 'value' for header X-ELS-Insttoken.".
I have assigned the API key through --> Add Elsevier_API = "API KEY GOES HERE" to ~/.Renviron file. To assign the insttoken I used the following:

token <- "my_insttoken_goes_here"
>inst_token_header(token)
$`X-ELS-Insttoken`
[1]  "my_insttoken_goes_here"
> have_api_key()
[1] TRUE

But still when I try to use any function, it returns authentication error:

> auth_info = process_author_name(last_name = "Muschelli", first_name = "John",  verbose = FALSE)
$`service-error`
$`service-error`$status
$`service-error`$status$statusCode
[1] "AUTHENTICATION_ERROR"

$`service-error`$status$statusText
[1] "Invalid API Key."

Error in get_complete_author_info(...) : Service Error
> 

Any suggestions on how to include the insttoken?

Thanks in advance.

muschellij2 commented 5 years ago

To use an AuthToken (not an Institution token), I've added the part it to the README, but I haven't tried it out really.

But, as per https://dev.elsevier.com/tecdoc_api_authentication.html: "Using a proprietary token (an "Institutional Token") created for you by our integration support team", so you need to contact Scopus.

John

On Thu, Jan 31, 2019 at 4:07 AM rashi-goyal notifications@github.com wrote:

Hi.. I am also facing authentication issues. Since I am located remotely, i have received an insttoken from Scopus to enable API access from outside the institute's network. But I am not able to use it correctly. As per Scopus, I have to "send it in addition to APIKey, with every request and set it as the 'value' for header X-ELS-Insttoken.". I have assigned the API key through --> Add Elsevier_API = "API KEY GOES HERE" to ~/.Renviron file. To assign the insttoken I used the following:

token <- "my_insttoken_goes_here"

inst_token_header(token) $X-ELS-Insttoken [1] "my_insttoken_goes_here" have_api_key() [1] TRUE

But still when I try to use any function, it returns authentication error:

auth_info = process_author_name(last_name = "Muschelli", first_name = "John", verbose = FALSE) $service-error $service-error$status $service-error$status$statusCode [1] "AUTHENTICATION_ERROR"

$service-error$status$statusText [1] "Invalid API Key."

Error in get_complete_author_info(...) : Service Error

Any suggestions on how to include the insttoken?

Thanks in advance.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/muschellij2/rscopus/issues/16#issuecomment-459269449, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBnrrqE-oMgF0CzSjQKm4ReUVSwUvOTks5vIrI3gaJpZM4aN7Uu .