adsabs / adsabs-dev-api

Developer API service description and example client code
163 stars 58 forks source link

Unauthorized/404 response to libraries API #23

Closed andycasey closed 8 years ago

andycasey commented 8 years ago

Hola compadres,

I've branched the ADS client with the aim to make use of the libraries API, but I am encountering some rudimentary troubles. In short, I am getting 404's or unauthorized responses to a simple get method to list all my private libraries:

 ads arc$ curl -H 'Authorization: Bearer <TOKEN>' 'https://api.adsabs.harvard.edu/v1/biblib/'
{
  "error": "Not found"
}ads arc$ curl -H 'Authorization: Bearer <TOKEN>' 'https://api.adsabs.harvard.edu/v1/biblib'
{
  "error": "Not found"
}ads arc$ curl -H 'Authorization: Bearer <TOKEN>' 'https://api.adsabs.harvard.edu/v1/biblib/libraries'
{
  "error": "Unauthorized"
}ads arc$ curl -H 'Authorization: Bearer <TOKEN>' 'https://api.adsabs.harvard.edu/v1/biblib/libraries/'
{
  "error": "Unauthorized"
}

(Obviously, <TOKEN> has been replaced here with my real token)

I have one library in BBB, which is public but has no documents. Where have I screwed up here?

Thanks!

jonnybazookatone commented 8 years ago

I'll take a look. Most likely related to our internal scopes (permissions) that have 'user' scope. The ones that don't have this scope (I think libraries/library_id is the only one) should work for the time being.

andycasey commented 8 years ago

Thanks @jonnybazookatone.

The library_id seems to be only available through the API (I cannot find it on the BBB UI). For that reason I can't seem to confirm on my side whether libraries/library_id works for me or not because I can't create a new library via the API or get the IDs of existing ones created via the UI.

Let me know if there's anything I can do to help debug.

jonnybazookatone commented 8 years ago

(a slightly hackish way) You can get the ID by going to 'Manage Permissions' via the button on your libraries page and press 'make public', and the URL it gives you has an ID at the end, e.g.,
ui.adsabs.harvard.edu/#/public-libraries/PMOjzfbbTZKShRWvIZF6cg

the library id here is PMOjzfbbTZKShRWvIZF6cg. I tested and this works. Don't worry about any debugging, I'll let you know once I've put a fix in place.

Sorry it didn't work straight off the bat.

andycasey commented 8 years ago

Thanks for the library ID tip. No need to apologise!

On Wed, Nov 18, 2015 at 4:38 PM Jonny Elliott notifications@github.com wrote:

(a slightly hackish way) You can get the ID by going to 'Manage Permissions' via the button on your libraries page and press 'make public', and the URL it gives you has an ID at the end, e.g.,

ui.adsabs.harvard.edu/#/public-libraries/PMOjzfbbTZKShRWvIZF6cg

the library id here is PMOjzfbbTZKShRWvIZF6cg. I tested and this works. Don't worry about any debugging, I'll let you know once I've put a fix in place.

Sorry it didn't work straight off the bat.

— Reply to this email directly or view it on GitHub https://github.com/adsabs/adsabs-dev-api/issues/23#issuecomment-157769251 .

jonnybazookatone commented 8 years ago

Should be working now. JSON variable defined with '' instead of "" can cause a little bit of havoc :-).

andycasey commented 8 years ago

Hmm, I'm still having troubles on my end:

arc$ curl -H 'Authorization: Bearer <API_TOKEN>' 'https://api.adsabs.harvard.edu/v1/biblib/libraries'
{
  "error": "Unauthorized"
}
arc$ curl -H 'Authorization: Bearer <API_TOKEN>' 'https://api.adsabs.harvard.edu/v1/biblib/libraries/'
{
  "error": "Unauthorized"
}

My ADS username is arc, should I email you my API token to see if you get the same behaviour using my token on your end?

jonnybazookatone commented 8 years ago

Don't worry, I had your token, I just tried the wrong one. It should work now - let me know if it doesn't

curl -H "Authorization: Bearer <TOKEN>" https://api.adsabs.harvard.edu/v1/biblib/libraries
{"libraries": [{"num_documents": 0, "date_last_modified": "2015-11-04T21:03:58.873838",
......
}]}
andycasey commented 8 years ago

Woohoo! It works. Thanks @jonnybazookatone!