Skip to content

Instantly share code, notes, and snippets.

@chriskief
Last active December 26, 2015 09:39
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/7130862 to your computer and use it in GitHub Desktop.
Save chriskief/7130862 to your computer and use it in GitHub Desktop.
def verify(request):
# Facebook will direct with state and code in the URL
# ?state=ebK3Np...&code=AQDJEtIZEDU...#_=_
# ensure we have a session state and the state value is the same as what facebook returned
# also ensure we have a code from facebook (not present if the user denied the application)
if 'facebook_state' not in request.session \
or 'state' not in request.GET \
or 'code' not in request.GET \
or request.session['facebook_state'] != request.GET['state']:
return False
else:
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment