Skip to content

Instantly share code, notes, and snippets.

@chriskief
Created October 24, 2013 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriskief/7130876 to your computer and use it in GitHub Desktop.
Save chriskief/7130876 to your computer and use it in GitHub Desktop.
def verify(request):
# Twitter will direct with oauth_token and oauth_verifier in the URL
# ?oauth_token=EoSsg1...&oauth_verifier=NB3bvAkb...
# did the user deny the request
if 'denied' in request.GET:
return False
# ensure we have a session state and the state value is the same as what twitter returned
if 'twitter_request_token_key' not in request.session \
or 'oauth_token' not in request.GET \
or 'oauth_verifier' not in request.GET \
or request.session['twitter_request_token_key'] != request.GET['oauth_token']:
return False
else:
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment