Beispiel #1
0
def verify_auth(request):
    """Handle the redirect from foursquare as part of the oauth process."""

    service = get_model_instance(request.user, MODULE_NAME)
    request_token = RequestToken.objects.get(service=service)
    request_token.oauth_verify = request.GET.get('oauth_verifier')
    request_token.save()

    generate_access_token(service, request_token)
    service.setup = True
    service.public = True
    service.save()
    request_token.delete()

    return redirect(settings_redirect(request))
Beispiel #2
0
def verify_auth(request):
    """Take incoming request and validate it to create a valid AccessToken."""
    service = get_model_instance(request.user, PACKAGE)
    service.auth.request_token.oauth_verify = request.GET.get('oauth_verifier')
    service.auth.request_token.save()
    
    if not generate_access_token(service, "https://twitter.com/oauth/access_token"):
        messages.error(
                        request,
                        'Unable to validate your account with Twitter, please grant gargoyle.me access.'
                    )
        return HttpResponseRedirect(settings_redirect(request))

    # Mark as setup completed
    service.setup = True

    # Test if service is protected on twitter's side
    # if so mark it
    twitter_user = get_user(service)
    if twitter_user.protected:
        service.public = False
    else:
        service.public = True

    service.save()

    return HttpResponseRedirect(settings_redirect(request))
Beispiel #3
0
def verify_auth(request):
    """Take incoming request and validate it to create a valid AccessToken."""
    service = get_model_instance(request.user, PACKAGE)
    service.auth.request_token.oauth_verify = request.GET.get('oauth_verifier')
    service.auth.request_token.save()
    
    if not generate_access_token(service, service.app.auth_settings['access_token_url']):
        messages.error(
                        request,
                        'Unable to validate your username with Flickr, please check grant permission for gargoyle.me to access your photos.'
                    )
        return HttpResponseRedirect(settings_redirect(request))

    ## Mark as setup completed
    service.setup = True

    ## Test if service is protected on twitter's side
    ## if so mark it
    #twitter_user = get_user(service)
    #if twitter_user.protected:
        #service.public = False
    #else:
        #service.public = True

    service.save()

    return redirect(settings_redirect(request))
Beispiel #4
0
def verify_auth(request):
    """Take incoming request and validate it to create a valid AccessToken."""
    service = get_model_instance(request.user, MODULE_NAME)
    request_token = RequestToken.objects.get(service=service)
    request_token.oauth_verify = request.GET.get('oauth_verifier')
    request_token.save()
    generate_access_token(service, request_token)

    # Mark as setup completed
    service.setup = True

    # test if service is protected on twitter's side
    # if so mark it
    service_auth = _auth(service.app.oauth)
    user = tweepy.API(service_auth).get_user('twitter')
    service.public = False
    if not user.protected:
        service.public = True

    service.save()

    request_token.delete()
    return HttpResponseRedirect(settings_redirect(request))