Open joelczinn opened 11 months ago
Hello,
Thank you for reaching out to ADS. Looking at the code you provided, I think the issue may be a subtle difference in formatting in this line here:
headers={'Authorization': 'Bearer:TOKEN'},
The authentication methods are very sensitive to syntax, so this line should really be
headers={'Authorization': 'Bearer TOKEN'},
like it is in the cURL
.
-H 'Authorization: Bearer TOKEN'
I hope this helps,
-Taylor
Hello,
I'm coming back to this to clarify that changing Bearer:TOKEN to Bearer TOKEN did not work... Are there any other ideas of what might be going on?
Thanks again!
Hello,
I took the python code you provided and ran it against python-3.8
and requests-v2.31.0
but could not reproduce the issue with my personal token. I modified the code slightly and confirmed this is working.
import requests
TOKEN=REPLACE_TOKEN
bibcodes="bibcode\n1907AN....174...59.\n1908PA.....16..445.\n1989LNP...334..242S"
r = requests.post('https://api.adsabs.harvard.edu/v1/search/bigquery',
params={'q':'*:*', 'wt':'json', 'fq':'{!bitset}', 'fl':'bibcode'},
headers={'Authorization': 'Bearer '+str(TOKEN)},
data=bibcodes)
print(r.text)
For more detailed troubleshooting if this doesn't solve the issue, can you send an email with a detailed description of your current issue, as well as the goal of your queries, to adshelp[at]cfa.harvard.edu?
Thanks,
Taylor
Hello,
Thanks so much for this service. I would love to take advantage of it, but I'm running into an authorization issue, it seems.
I would expect the following code to work:
However, the result is:
However, the equivalent request via curl:
works and returns:
requests is v2.31.0 and Python is v3.8.6.
Thanks in advance for the help!