Open Cobertos opened 3 years ago
Ah, whoops! I had this snippet in my secrets.py
file
# https://stackapps.com/apps/oauth/view/16169
# TODO move that to stexport instead?
def get_token():
from subprocess import check_call
from urllib.parse import urlencode
# https://api.stackexchange.com/docs/authentication
qs = [
('client_id' , client_id),
('redirect_uri', redirect_uri),
# https://api.stackexchange.com/docs/authentication#scope
('scope' , 'private_info no_expiry')
]
url = 'https://stackoverflow.com/oauth/dialog?' + urlencode(qs)
check_call(['xdg-open', url])
print("Now copy acces_token and put it in the script")
if __name__ == '__main__':
get_token()
I guess makes sense to implement --login
mode or something, similar to instapexport, for example: https://github.com/karlicoss/instapexport#setting-up
It seems like access_token is needed, and requires an implicit OAuth 2.0 flow (or that seems the easiest). I get
xtackapi.stackapi.StackAPIError: ('https://api.stackexchange.com/2.2/sites/?pagesize=1000&page=1&filter=xxx&key=xxx&access_token=asdf', 403, 'access_denied', '
keyis not valid for passed
access_token, token not found (does not exist).')
without itI ended up:
Enable Client Side OAuth Flow
https://stackoverflow.com/oauth/dialog?client_id=[client_id]&scope=private_info,no_expiry&redirect_uri=https://stackexchange.com
according to the auth docsIt's verbose to add all of that to the README.md, but may be nice to specify you'll have to manually do the OAuth 2.0 flow yourself. Either in browser or Insomnia or something