Exemplo n.º 1
0
def refresh_access_token(token, user):
    token = get_refreshed_token(token)
    if not user.is_authenticated():
        return token
    try:
        ts = TokenStorageModel.objects.get(id=user)
    except TokenStorageModel.DoesNotExist:
        ts = TokenStorageModel(id=user)
    ts.token = gdata.gauth.token_to_blob(token)
    ts.save()
    return token
Exemplo n.º 2
0
def refresh_access_token(token, user):
    token = get_refreshed_token(token)
    if not user.is_authenticated():
        return token
    try:
        ts = TokenStorageModel.objects.get(id=user)
    except TokenStorageModel.DoesNotExist:
        ts = TokenStorageModel(id=user)
    ts.token = gdata.gauth.token_to_blob(token)
    ts.save()
    return token
Exemplo n.º 3
0
def google_auth_return(request):
    if 'code' not in request.REQUEST:
        return HttpResponse(u"Invalid Request")
    if request.user.is_authenticated():
        try:
            ts = TokenStorageModel.objects.get(id=request.user)
        except TokenStorageModel.DoesNotExist:
            ts = TokenStorageModel(id=request.user)
        access_token = oauth2_token.get_access_token(request.REQUEST)
        ts.token = gdata.gauth.token_to_blob(token=access_token)
        ts.save()
    else:
        access_token = oauth2_token.get_access_token(request.REQUEST)
        request.session["access_token"] =\
            gdata.gauth.token_to_blob(token=access_token)
    if request.session.get('google_redirect_url'):
        return HttpResponseRedirect(request.session.get('google_redirect_url'))
    return HttpResponseRedirect(reverse(home))
Exemplo n.º 4
0
def google_auth_return(request):
    if 'code' not in request.REQUEST:
        return HttpResponse(u"Invalid Request")
    if request.user.is_authenticated():
        try:
            ts = TokenStorageModel.objects.get(id=request.user)
        except TokenStorageModel.DoesNotExist:
            ts = TokenStorageModel(id=request.user)
        access_token = oauth2_token.get_access_token(request.REQUEST)
        ts.token = gdata.gauth.token_to_blob(token=access_token)
        ts.save()
    else:
        access_token = oauth2_token.get_access_token(request.REQUEST)
        request.session["access_token"] =\
            gdata.gauth.token_to_blob(token=access_token)
    if request.session.get('google_redirect_url'):
        return HttpResponseRedirect(request.session.get('google_redirect_url'))
    return HttpResponseRedirect(reverse(home))