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

Error 405: key is required when access token is passed #40

Open
aleksandra-asanin opened this issue Jun 22, 2020 · 2 comments
Open

Error 405: key is required when access token is passed #40

aleksandra-asanin opened this issue Jun 22, 2020 · 2 comments

Comments

@aleksandra-asanin
Copy link

aleksandra-asanin commented Jun 22, 2020

Hello!

I registered my application thus obtained app key and access token. By reading the documentation I figured out that it's possible to pass additional arguments into the fetch method, as soon as they are named the same as described in the endpoint documentation.

Sounds great. So I tried

SITE.fetch('users/{ids}/top-answer-tags', ids=user_id, access_token=access_token, key=key)

And got

stackapi.stackapi.StackAPIError: ('https://api.stackexchange.com/2.2/users/922184/top-answer-tags/?pagesize=1&page=1&filter=default&access_token=xxxxxxxxxxxxxxxx&site=stackoverflow', 405, 'key_required', 'keyis required whenaccess_token is passed.')

I obviously passed the key, but for some reason it doesn't appear in the url. Why is that?

If I take this url and add the key manually and test it in the browser, it works perfectly! Would be nice if this is fixed :)

@AWegnerGitHub
Copy link
Owner

Can you try this for me?

SITE = StackAPI('stackoverflow', key=key, access_token=access_token)

You didn't share, but I suspect your SITE is declared like this, correct:

SITE = StackAPI('stackoverflow')

There is an error where I'm not using a passed token or key in fetch.

@aleksandra-asanin
Copy link
Author

Sorry for the late response. I discovered already that it works by passing the arguments to the SITE object. Works perfectly, with Stackoverflow as well as with other sites from the Stack Exchange network. However, I would suggest to improve the package documentation a bit. It is more powerful than one might gain an impression by referring to docs.
Nevertheless, the package is awesome.
Kind regards!

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