示例#1
0
def auth(request):
    client_id, client_secret, callback = get_consumer_credentials()

    # start the OAuth process, set up a handler with our details
    oauth = OAuthHandler(client_id, client_secret, callback)
    # direct the user to the authentication url
    auth_url = oauth.get_authorization_url()
    response = HttpResponseRedirect(auth_url)

    return response
示例#2
0
def callback(request):
    verifier = request.GET.get('code')
    client_id, client_secret, callback = get_consumer_credentials()
    oauth = OAuthHandler(client_id, client_secret, callback)

    # get the access token and store
    try:
        oauth.get_access_token(verifier)
    except FoursquareError:
        print 'Error, failed to get access token'
    request.session['oauth_token'] = oauth.access_token
    response = HttpResponseRedirect(reverse('info'))
    return response