Nasdaq / data-link-python

A Python library for Nasdaq Data Link's RESTful API
MIT License
428 stars 70 forks source link

strip api key #13

Closed wshclth closed 2 years ago

wshclth commented 2 years ago

The api key loaded during initialization causes it to include a new line character. As a result the new line is passed onto the HTTP request which results in an error during any HTTP request.

ValueError: Invalid header value b'[redacted_key]\n'

This problem is solved by stripping the key during an initial loading of white space present before or after the API text. Strip is safe to use here because it will never strip data inside the key, only leading and trailing white space will be removed.

couture-ql commented 2 years ago

Hi there,

We recently merged https://github.com/Nasdaq/data-link-python/pull/11 which tries much harder to strip whitespace and find the api key. Apparently there's still an edge-case that wasn't covered in one of the introduced tests?

I should note that a release has yet to be sent up to pypi.org. A release is forthcoming.

couture-ql commented 2 years ago

1.0.1 has been pushed to pypi. If you can re-try your use-case and let us know if your issue has been resolved.

I've opened issue #14 to collect any further issues users have, as it is recognized cleaning whitespace isn't solved for env-var use-cases.

wshclth commented 2 years ago

Good Morning, The API key stripping related to reading from a file is fixed now.