def two_legged(request): requestor_id = request.GET.get("user") if not requestor_id: requestor_id = request.session.get("openid_data", {}).get("email") if not requestor_id: return render(request, "core/two_legged_error.html", {"error": "Requestor Id is not defined"}) client = DocsClient(source=settings.USER_AGENT) client.auth_token = TwoLeggedOAuthHmacToken(settings.CONSUMER_KEY, settings.CONSUMER_SECRET, requestor_id) try: documents = client.get_all_resources() except Unauthorized, e: return render(request, "core/two_legged_error.html", {"error": e})
def oauth_gdocs(request, access_token): client = DocsClient(source=settings.USER_AGENT) client.auth_token = access_token documents = client.get_all_resources() return render(request, "core/oauth_gdocs.html", {"documents": documents})