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

Invalid API key #9

Closed
khoadng opened this issue Mar 3, 2021 · 4 comments
Closed

Invalid API key #9

khoadng opened this issue Mar 3, 2021 · 4 comments
Assignees

Comments

@khoadng
Copy link

khoadng commented Mar 3, 2021

Got this error when running this code snippet

Error

Exception has occurred: BadKeyError
Invalid API key
  File "C:\Users\Admin\Projects\test.py", line 4, in <module>
    results = sauce.from_url('https://i.imgur.com/oZjCxGo.jpg')  # or from_file()

Code

from saucenao_api import SauceNao

sauce = SauceNao()
results = sauce.from_url('https://i.imgur.com/oZjCxGo.jpg')  # or from_file()

best = results[0]  # results sorted by similarity
print(best.author)

Do I need to provide an API key or something?

@nomnoms12 nomnoms12 added the bug Something isn't working label Mar 3, 2021
@nomnoms12 nomnoms12 self-assigned this Mar 3, 2021
@nomnoms12
Copy link
Owner

The error occurred because the server returned an HTTP 403 Forbidden response:

{'header': {'status': -1, 'message': 'The anonymous account type does not permit API usage.'}}

SauceNao probably no longer supports anonymous requests, and yes, you will have to register and pass an API key with every request. (With the key, the request is successful.)

@nomnoms12
Copy link
Owner

@khoadng You have to pass the API key to the SauceNao class:

# Replace the key with your own
sauce = SauceNao('077f16b38a2452401790540f41246c7d951330c0')

To get the key, register using the link: https://saucenao.com/user.php?page=search-api

@nomnoms12
Copy link
Owner

I think this can't be considered a bug in the library. If SauceNao's policy doesn't change in the next few days, I'll make api_key a required parameter and update the examples.

@nomnoms12 nomnoms12 removed the bug Something isn't working label Mar 3, 2021
@nomnoms12 nomnoms12 pinned this issue Mar 3, 2021
nomnoms12 pushed a commit that referenced this issue Mar 3, 2021
@khoadng
Copy link
Author

khoadng commented Mar 4, 2021

Other than this, everything works flawlessly. Nice work!
Thanks for this awesome library.

@khoadng khoadng closed this as completed Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants