Py-StackExchange icon indicating copy to clipboard operation
Py-StackExchange copied to clipboard

stackexchange.core.StackExchangeError: 406 [access_token_compromised]: Access token sent over non-HTTPS request, it has been invalidated

Open 90abyss opened this issue 9 years ago • 1 comments

I need the json to return "accepted_answer" as one of the fields, which requires me to send access_token when I call the StackExchange API. I'm getting this error:

stackexchange.core.StackExchangeError: 406 [access_token_compromised]: Access token sent over non-HTTPS request, it has been invalidated

This is how I'm trying to do it:

so = stackexchange.Site(stackexchange.StackOverflow, 'myappkey')
so.impose_throttling = True
so.throttle_stop = False
posts = so.recent_questions(pagesize=10, filter ='!-rN2FZQY', access_token = 'xxx')

How can I fix this?

90abyss avatar Apr 04 '16 21:04 90abyss

Hello,

Retrieving the accepted_answer field on its own shouldn't require an access token — indeed, the field is part of the default filter. A separate issue in the library led to it not being included on the question object, but I've fixed that in commit 715b77f4. Bear in mind that the field isn't included on questions which don't have an accepted answer yet.

I've also switched the library to use HTTPS by default (commit 2222c2bc), so any other calls that require an access token should now work. You may need to regenerate the one you were using in the above example, however.

Either way, if you update to the latest master, everything should work.

Thanks, and please let me know if that works for you now :)

lucjon avatar Apr 08 '16 13:04 lucjon