Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not retrieve data - verify API key #1

Closed
kajhoej opened this issue Nov 7, 2019 · 12 comments · Fixed by #4
Closed

Could not retrieve data - verify API key #1

kajhoej opened this issue Nov 7, 2019 · 12 comments · Fixed by #4
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@kajhoej
Copy link

kajhoej commented Nov 7, 2019

I'm trying to get your fine integration to work, but I keep getting this error in my logs.

I have verified that I have a correct API Key for ynab. I have some automations i Node-red which uses the ynab API so I know the API keys are working.

I'm using version 0.1.3 from HACS

My config configuration.yaml looks like this

ynab:
  api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

The only thing the logs say are:

2019-11-07 23:30:48 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.ynab
2019-11-07 23:30:49 ERROR (MainThread) [custom_components.ynab] Could not retrieve data - verify API key
@wxt9861
Copy link
Owner

wxt9861 commented Nov 10, 2019

Hi.

Do you also get the same error if you specify a budget id?

ynab:
  api_key: <api_key_here>
  budget: <budget_id_here>

I will also take a look at adding better debug logging in the next few days so these types of issues are easier to troubleshoot.

@wxt9861 wxt9861 self-assigned this Nov 10, 2019
@wxt9861 wxt9861 added bug Something isn't working enhancement New feature or request labels Nov 10, 2019
@kajhoej
Copy link
Author

kajhoej commented Nov 10, 2019

Yes, No difference adding the budget id.

@wxt9861
Copy link
Owner

wxt9861 commented Nov 12, 2019

I am unable to reproduce the error unless I enter a wrong API key. Unfortunately, the python package used for this component does not provide much information about the connection it makes, so if the API key is correct, its a guessing game of what else it can be.

There is another API available for YNAB which looks more capable and I might just have to rewrite the component to use that.

The only other thing, when you enter the API key, do you put it in quotes or without? I haven't tested it (will tomorrow) and don't think it would matter, but worth a check.

Like this?

ynab:
  api_key: "my_api_key_here"

@kajhoej
Copy link
Author

kajhoej commented Nov 12, 2019

I tried with "" around the api_key as you suggested but no change.

On my laptop I installed python3.7 and the ynab-api you use and tried a small test program that was shown in their README.md file.

from ynab_sdk import YNAB

ynab = YNAB('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
print(ynab.budgets.get_budgets())

This works fine. So very strange.

More info about my instsallation in case its needed:

arch x86_64
dev false
docker true
hassio true
os_name Linux
python_version 3.7.4
timezone Europe/Copenhagen
version 0.100.3
virtualenv false

@wxt9861
Copy link
Owner

wxt9861 commented Nov 13, 2019

Strange indeed. The sucky thing is the API doesn't provide connection details, it throws a generic error. I looked at using another API, but it does not support python3.7 at this time.

Back to the drawing board, I just need to figure out how to replicate the error - the only way I can do it now is by entering a wrong API key, but thats not the issue here.

@wxt9861 wxt9861 mentioned this issue Nov 13, 2019
@wxt9861
Copy link
Owner

wxt9861 commented Nov 13, 2019

Can you please try release v0.1.4? i added a function to check if HASS can communicate with YNAB API endpoint. This will at least verify we are able to establish a connection before API key gets involved.

Successful result will be displayed if you have debugging enabled
Failed results will be displayed as an error

@kajhoej
Copy link
Author

kajhoej commented Nov 13, 2019

I have upgraded to v0.1.4 and have snipped the following the log:

2019-11-13 21:06:33 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for ynab which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
...
2019-11-13 21:06:34 INFO (MainThread) [homeassistant.setup] Setting up ynab
2019-11-13 21:06:34 INFO (MainThread) [custom_components.ynab] 
-------------------------------------------------------------------
ynab
Version: 0.1.4
This is a custom component
If you have any issues with this you need to open an issue here:
https://github.com/wxt9861/ynab/issues
-------------------------------------------------------------------

2019-11-13 21:06:34 DEBUG (MainThread) [custom_components.ynab] Connection with YNAB established
2019-11-13 21:06:34 DEBUG (MainThread) [custom_components.ynab] Using budget - last-used
2019-11-13 21:06:34 DEBUG (MainThread) [custom_components.ynab] Monitoring categories - []
2019-11-13 21:06:34 INFO (MainThread) [homeassistant.setup] Setup of domain ynab took 0.5 seconds.
...
2019-11-13 21:06:49 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.ynab
...
2019-11-13 21:06:50 ERROR (MainThread) [custom_components.ynab] Could not retrieve data - verify API key 
...
2019-11-13 21:11:57 ERROR (MainThread) [custom_components.ynab] Could not retrieve data - verify API key 
...
2019-11-13 21:17:04 ERROR (MainThread) [custom_components.ynab] Could not retrieve data - verify API key 
...

@quinnhosler
Copy link
Contributor

I just took a moment to look into this, and it appears the problem is within the ynab_sdk component itself.

I submitted a pull request on the original repository. I don't know how long this takes to make it to the pip install, but the changes can be made manually. They're very minor.

Find changes here.

@burnnat
Copy link
Contributor

burnnat commented Feb 14, 2020

@quinnhosler Thanks for the patch, I applied the changes manually in my site-packages and that solved the issue for me. I didn't see any open PR here, am I looking at the right repo? Would be nice to get a published version so I don't have to worry about losing the changes.

@quinnhosler
Copy link
Contributor

Definitely thought I had opened a PR. I went ahead and opened one; hopefully it'll be merged sooner than later.

Glad the changes worked for you!

@burnnat
Copy link
Contributor

burnnat commented Feb 17, 2020

Looks like ynab-sdk 0.0.4 was published including the parser fix! @wxt9861, any chance for a new version with the updated dependency?

burnnat added a commit to burnnat/ynab that referenced this issue Mar 7, 2020
@wxt9861 wxt9861 closed this as completed in #4 Mar 9, 2020
wxt9861 added a commit that referenced this issue Mar 9, 2020
Update ynab-sdk dependency (resolves #1)
@akcamperdude
Copy link

I'm seeing the same issue on the latest release...no info except that the token doesn't work. Even created a new token and doesn't work. api_key is the only option I'm specifying in my config. I have a couple older budgets but specifying one doesn't seem to make a difference.

Logger: custom_components.ynab
Source: custom_components/ynab/init.py:209
Integration: ynab (documentation)
First occurred: 3:37:14 PM (1 occurrences)
Last logged: 3:37:14 PM

Could not retrieve data - verify API key

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants