UnauthorizedError error: The credentials provided are invalid.

19 views
Skip to first unread message

bkjo...@ucdavis.edu

unread,
Mar 23, 2019, 8:12:29 PM3/23/19
to Dataverse Users Community

I'm a relatively new programmer and I'm having the most beginner type of problem.

I've been attempting to use the Python client library (https://github.com/IQSS/dataverse-client-python) but I keep getting an UnauthorizedError exception after a Connection(host, token) call: "The credentials provided are invalid."

Any idea why this might be happening? I've
1. installed the client with pip
2. verified my email,
3. linked it with my institution,
4. input the correct API token generated for my account.

I'm attempting to access 'demo.dataverse.org' according to the Usage cell (and have also attempted to use the demo's key '4d0634d3-74d5-4770-8088-1971847ac75e' to no avail).

Philip Durbin

unread,
Mar 26, 2019, 7:40:03 AM3/26/19
to dataverse...@googlegroups.com
Hi! Thanks for trying out the Dataverse APIs.

I was able to reproduce your problem with my own API token on https://demo.dataverse.org ("403 Not Authorized").

Then I clicked "Recreate Token" and my new token worked. This shouldn't be necessary (and I hope there isn't a bug lurking somewhere) but can you please give this a try and report back? (Others are welcome to try and report back as well.) Very strange. I also repeated the same procedure with my account on Harvard Dataverse but my existing API token worked fine. I didn't have to recreate it. I'm not sure what's going on but thanks for reporting this.

Thanks!

Phil

p.s. Public Service Announcement: You should treat API tokens with the same care you treat passwords. Please keep it secret, keep it safe.


--
You received this message because you are subscribed to the Google Groups "Dataverse Users Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dataverse-commu...@googlegroups.com.
To post to this group, send email to dataverse...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dataverse-community/b355d4fd-54a5-4185-80cf-ad811e699a8e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Benjamin Johnson

unread,
Mar 28, 2019, 5:53:02 PM3/28/19
to dataverse...@googlegroups.com
Hi Philip,

No, same issue. Recreated tokens on my official university account AND an alternate personal account.

My code looks something like this, if it helps:




from dataverse import Connection

host = 'demo.dataverse.org'
token = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'

connection = Connection(host = host, token = token)

Philip Durbin

unread,
Mar 28, 2019, 6:24:23 PM3/28/19
to dataverse...@googlegroups.com
Can you please try curl for now? Please substitute your API token in the example below (you should never email around tokens like this because they are like passwords and I'm about to to recreate mine):


Yes, you need that colon after the token. Please let us know if it works. You should get some XML back, a list of places (dataverses) you can deposit to.

Thanks,

Phil


For more options, visit https://groups.google.com/d/optout.

Benjamin Johnson

unread,
Mar 28, 2019, 7:07:07 PM3/28/19
to dataverse...@googlegroups.com
Hi Phil,

Yes, it does work! I do receive an XML response.

Though, I should clarify: my purpose is rudimentary enough that I don't need to deposit anything, only download publicly viewable datasets (perhaps I'm remiss using the API client for this?) and possibly collect some metadata. I'm only looking to:
  1. automate the download of regularly uploaded files on a dataverse dataset
  2. if possible, collect metadata on the history of individual files' a) upload and b) update time (date is easily viewable for each, but time would be more useful)
I've also switched to using the R client for now, with some problems--example code breaks for me in some cases, though I work around it easily enough. I'm getting what I need for 1., though having trouble with 2. Again, I'm a very new undergraduate programmer, not studying CS, so I apologize if I have simply overlooked easy solutions to these simple tasks in the docs or forums--I'm not always 100% sure what to look for.

I greatly appreciate all of your help and prompt responses so far!

Thanks,
Ben Johnson

Philip Durbin

unread,
Mar 28, 2019, 7:39:45 PM3/28/19
to dataverse...@googlegroups.com
Hmm, well, the Search API will give you "published_at" timestamps, if that helps. (I looked through our export formats, DDI etc., and didn't see dates or timestamps for individual files, but maybe I missed something.) I may not be fully following all of your requirements but please feel free to hit me up with questions tomorrow at http://chat.dataverse.org . We're always interested in improving our APIs.

I'm glad you got your API token working. Fun fact: the Search API doesn't even require one! :)

Thanks,

Phil


For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages