peeter123 / digikey-api

Python module for the Digikey PartSearch API
GNU General Public License v3.0
85 stars 35 forks source link

Issues with fake-useragent and proxy server #11

Closed clAntHri closed 2 years ago

clAntHri commented 3 years ago

First of all thank you for writing this interface and making it available! I encountered two issues when setting it up last week and wanted to let you know:

  1. The package 'fake-useragent' seems to be used to generate http user-agent headers. This package seems to be quite 'smart' and uses a 3rd party server for generating these headers. Unfortunately there seems to be something broken and the package threw an exception (or the package couldn't handly my proxy settings). So I replaced the calls to fake-useragent with static user-agent strings.

  2. I'm in a corporate setting behind a proxy and my system is configured with a proxy path environment variable (Windows). While the Oauth2 mechanism works fine with digikey over the proxy out of the box, the actual requests to the API are always configured to proxy=none. So I added to the constructor of the class DigikeyApiWrapper: configuration.proxy = os.environ['HTTPS_PROXY']

Now it's working just fine.

Hope that helps!

eeintech commented 3 years ago

@clAntHri Do you mind creating a PR for your proposed improvements?

makew0rld commented 3 years ago

I removed the dependency on fake-useragent in #24.