Closed TotallyNotTito closed 1 year ago
I'm able to use the same API key as an environmental variable and pass that to the url endpoint to work with NPS API, but passing it via the above method hasn't worked with the request.Request() method
Hello, Tito
Based on what I can see, it looks like there might be a mismatch between the documentation (i.e. https://www.nps.gov/subjects/developer/guides.htm) and the implementation.
I've been able to confirm the HTTP Basic Auth Username method does not work, but the GET Query parameter approach does. The HTTP Header approach works, but only when I use "X-Api-Key" and not when I use "Authorization"
May I ask you to please give that a try on your end to confirm, and let me know if it is successful, so I can update the code examples in the documentation accordingly? Thank you.
Good morning, @TotallyNotTito
Following up to see if you've had a chance to change your code from "Authorization" to "X-Api-Key", and if so, was the result successful?
Hey just seeing these. Apologies for the delayed response. I did confirm your results. I'm going to close this issue.
Happy New Year and hope you have been well. Thank you for following up!
HEADERS = {"Authorization":"INSERT-API-KEY-HERE"}
req = urllib.request.Request(endpoint,headers=HEADERS)
response = urllib.request.urlopen(req).read()