Skip to content

Instantly share code, notes, and snippets.

@gipi
Last active April 25, 2017 17:34
Show Gist options
  • Save gipi/82e1ff0a3e019bb5d91108464df189fb to your computer and use it in GitHub Desktop.
Save gipi/82e1ff0a3e019bb5d91108464df189fb to your computer and use it in GitHub Desktop.
#oauth #authorization
#!/usr/bin/env python2
from requests_oauthlib import OAuth2Session
client_id = 'LZAzNepabqtyGblg6uGhqiknaiDxX0LwTfYa0ZHr'
client_secret = '0icSnXkmyBQlZ93hBhj6dkI3DrKEyF5sXTqChkExQ9UxptQVqyAMOrLYc652OD7FRRSzSK2Jkb1q7HfA44adyftTzSD0cKBh1hfbQY4OtbK6bDVRcSLcsWNyiTMD8oxP'
redirect_uri = 'https://django-oauth-toolkit.herokuapp.com/consumer/exchange/'
oauth = OAuth2Session(client_id, redirect_uri=redirect_uri,)
#scope=scope)
authorization_url, state = oauth.authorization_url('https://localhost:8000/o/authorize')
print 'Please go to %s and authorize access.' % authorization_url
authorization_response = raw_input('Enter the full callback URL ')
token = oauth.fetch_token(
'https://localhost:8000/o/token/',
authorization_response=authorization_response,
client_secret=client_secret,
verify=False)
r = oauth.get('https://localhost:8000/api/v2/housedraft/?p=1')
print r.content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment