IQSS / dataverse-client-r

R Client for Dataverse Repositories
https://iqss.github.io/dataverse-client-r
61 stars 25 forks source link

get_user_key() #81

Closed Danny-dK closed 3 years ago

Danny-dK commented 3 years ago

Today I installed the dataverse library (from CRAN).

I use demo.dataverse.nl with an institutional University login (logging-in will redirect to the institutions login page).

I can get everything working when I specifically set the

Sys.setenv("DATAVERSE_SERVER" = "demo.dataverse.nl")
Sys.setenv("DATAVERSE_KEY" = "my key created on demo.dataverse.nl account")

but I'm wondering what the purpose is of get_user_key()? The help file indicates that this is for getting a user's API key or resetting the API key. When I try to use get_user_key("my username", "my password for my account") I'm getting a 'Bad Request (HTTP 400) error. I initially thought that it may be something with the institutional login, but I also created another account with a private emailaddress and the same error is thrown. I tried both entering my username and my emailaddress as the user part.

Am I misinterpreting the function of get_user_key()?

kuriwaki commented 3 years ago

I think the key is only necessary when you want to get data from a non-public datatset (i.e. requires a Dataverse login). Many datasets are actually public and don't require you to set a user key; maybe that's your use case. Key is also necessary for uploading and editing your own data.

The 404 error is a separate matter and we'll need to look into this.

pdurbin commented 3 years ago

what the purpose is of get_user_key()?

For a while Dataverse allowed certain users (builtin, not institutional) to look up their API token by passing their username and password. We later decided this is a bad idea and this functionality was disabled by default in https://github.com/IQSS/dataverse/commit/fd743e284c2dc870aaac5377d9e613c3e61c7c29

Danny-dK commented 3 years ago

Ah thanks, then it makes sense the get_user_key() is not working anymore. I'm assuming that the admin of a dataverse installation needs to make it TRUE to allow lookup of the key. Perhaps it can be added in the help file at get_user_key() that the function is disabled by default.