Beispiel #1
0
def api_auth(request):
    handler = OAuthHandler(settings.FF_API_KEY, settings.FF_API_SECRET)
    callback_url = request.GET.get('oauth_callback')
    if not callback_url:
        callback_url = request.build_absolute_uri(reverse('fanfou_oauth_callback'))
    url = handler.get_authorization_url(callback=callback_url)
    request.session['reqtoken'] = handler.request_token
    print handler.request_token
    return HttpResponseRedirect(url)
Beispiel #2
0
def api_auth(request):
    handler = OAuthHandler(settings.FF_API_KEY, settings.FF_API_SECRET)
    callback_url = request.GET.get('oauth_callback')
    if not callback_url:
        callback_url = request.build_absolute_uri(
            reverse('fanfou_oauth_callback'))
    url = handler.get_authorization_url(callback=callback_url)
    request.session['reqtoken'] = handler.request_token
    print handler.request_token
    return HttpResponseRedirect(url)
Beispiel #3
0
 def handle(self, **options):
     handler = OAuthHandler(settings.FF_API_KEY, settings.FF_API_SECRET)
     url = handler.get_authorization_url(callback='oob')
     request_token = handler.request_token
     print 'Open the url', url, 'to get pin code.'
     verifier = raw_input('PIN Code: ')
     handler = OAuthHandler(settings.FF_API_KEY, settings.FF_API_SECRET)
     handler.request_token = request_token
     access_token = handler.get_access_token(verifier=verifier)
     if access_token:
         print '# Put the following lines into settings.py'
         print "PUBLISHER_OAUTH_TOKEN = '%s'" % access_token.key
         print "PUBLISHER_OAUTH_SECRET = '%s'" % access_token.secret
Beispiel #4
0
def api_authcb(request):
    try:
        handler = OAuthHandler(settings.FF_API_KEY, settings.FF_API_SECRET)
        request_token = request.session.get('reqtoken', '')
        print 'request token', request_token
        handler.request_token = request_token
        token = handler.get_access_token(verifier=request.GET.get('verifier'))
        api = API(handler)
        u = get_user(api, oauth_token=token.key, oauth_token_secret=token.secret)
        u = authenticate(username=u.username, password='******')
        login(request, u)
        request.user = u
    except Exception, e:
        print 'got error ', e
        import traceback
        traceback.print_exc()
        logout(request)
Beispiel #5
0
def api_authcb(request):
    try:
        handler = OAuthHandler(settings.FF_API_KEY, settings.FF_API_SECRET)
        request_token = request.session.get('reqtoken', '')
        print 'request token', request_token
        handler.request_token = request_token
        token = handler.get_access_token(verifier=request.GET.get('verifier'))
        api = API(handler)
        u = get_user(api,
                     oauth_token=token.key,
                     oauth_token_secret=token.secret)
        u = authenticate(username=u.username, password='******')
        login(request, u)
        request.user = u
    except Exception, e:
        print 'got error ', e
        import traceback
        traceback.print_exc()
        logout(request)
Beispiel #6
0
 def handle(self, **options):
     handler = OAuthHandler(settings.FF_API_KEY, settings.FF_API_SECRET)
     url = handler.get_authorization_url(callback='oob')
     request_token = handler.request_token
     print 'Open the url', url, 'to get pin code.'
     verifier = raw_input('PIN Code: ')
     handler = OAuthHandler(settings.FF_API_KEY, settings.FF_API_SECRET)
     handler.request_token = request_token
     access_token = handler.get_access_token(verifier=verifier)
     if access_token:
         print '# Put the following lines into settings.py'
         print "PUBLISHER_OAUTH_TOKEN = '%s'" % access_token.key
         print "PUBLISHER_OAUTH_SECRET = '%s'" % access_token.secret