uberfastman / yfpy

Python API wrapper for the Yahoo Fantasy Sports public API (supports NFL, NHL, MLB, and NBA).
https://pypi.org/project/yfpy/
GNU General Public License v3.0
163 stars 44 forks source link

KeyError in example #10

Closed MLDERES closed 2 years ago

MLDERES commented 3 years ago

It seems that something is not quite right, or maybe I've not followed the instructions close enough. When I try to run the test_yfpf.py file I'm getting a KeyError: 'YFPY_CONSUMER_KEY'

  1. pip installed yfpy
  2. I followed all the steps and successfully got a ConsumerSecret and ConsumerKey from Yahoo.
  3. Created a copy of EXAMPLE_private.json into a local folder and renamed it to private.json.
  4. Copied test_yfpy.py into a folder
  5. Change league id to my own league id
  6. Run python -m test_yfpy.py
  7. KeyError

So I figured maybe this is because there was a change and environment variables were used instead, so I created a .env file (again same folder), and run python -m test_yfpy.py, same issue.

Running on Windows 10

jtvanlew commented 2 years ago

I was having the same problem. The issue is line 75 that's calling yahoo_query = YahooFantasySportsQuery(...)

I found a solution is if you leave offline = False, and then just comment out # consumer_key=os.environ["YFPY_CONSUMER_KEY"] and # consumer_secret=os.environ["YFPY_CONSUMER_SECRET"] then the function call will use your private.json to authenticate with yahoo

derektgardner commented 2 years ago

I was having the same problem. The issue is line 75 that's calling yahoo_query = YahooFantasySportsQuery(...)

I found a solution is if you leave offline = False, and then just comment out # consumer_key=os.environ["YFPY_CONSUMER_KEY"] and # consumer_secret=os.environ["YFPY_CONSUMER_SECRET"] then the function call will use your private.json to authenticate with yahoo

I can confirm that this fixes the issue.

uberfastman commented 2 years ago

Hi @MLDERES, my apologies for the very long delay in responding. Thank you @jtvanlew and @derektgardner for figuring out the issue for @MLDERES. I had updated the tests to use a .env file but had not updated the documentation, etc. I just published the latest release (v4.0.0) of YFPY and it includes fixes for this issue.