App Engine: Easier auth with OAuth2Decorator
Why Stack Overflow recommends it
Stack Overflow users link it when answering questions about OAuth2 on Google App Engine, since the decorator handles token storage, refresh and the callback handler for you.
Recommended by 5 people across 4 different months, 2014 to 2018.
What it is
A 35-minute Google for Developers session from the App Engine team on using OAuth2Decorator from google-api-python-client to handle authentication and authorization when calling Google APIs from a Python App Engine app. It walks through the decorator approach so auth takes far less effort than hand-rolled OAuth2 flows.
What people said
Recommends Ryan · 2014-08 · Stack Overflow · on “upload text file to google drive using python every 5 seconds”
If you use the decorator as seen in the video bellow it stores your access token in the db for you and handles refreshing when needed. [this video] [LINK] from oauth2client.appengine import OAuth2Decorator decorator = OAuth2Decorator(client_id=CLIENT_ID, client_secret=CLIENT_SECRET, scope=OAUTH_SCOPE, callback_path=REDIRECT_URI) class MainPage(webapp2.RequestHandler): @decorator.oauth_required #Simply place this above any function that requires login. def get(self):
Recommends Patrice · 2014-08 · Stack Overflow · on “Using OAuth2 token to authenticate to an API hosted on Google App Engine?”
I know answers shouldn't be links, but anyway, here is what I personally looked at to get a better understanding of App engine + Oauth 2.0 [this video]
Recommends Ryan · 2014-08 · Stack Overflow · on “Implementing OAUTH2 on an App Engine Project”
OAuth can be a beast to manage. Personally I do what they do here [this video] and use the decorator class. That way it will cover refreshes and many other beasts that show up. To get the users information user class [LINK] to get the users information. You can see it in action via their Tutorial [LINK] . You don't need to worry about the 'users.create_login_url' as theOAuth requires the log in anyways.
Recommends rob · 2016-06 · Stack Overflow · on “gae bigquery works from dev_appserver but credential errors during tests”
I'm going to poke at this, not sure how helpful it will be. Apologies. Is your app not authenticating with GAE in this instance or just big query? I struggled against a lot of the auth issues dealing with BT and App Engine. I'm trying to dig up my notes from when I dealt with it. The Google BigQuery analytics book is pretty solid if you are able to purchase it, but some of the Auth stuff is already out of date. If you type printenv (unix), do you see the GOOGLE_APPLICATION_CREDENTIALS path declared? I had issues where my env vars weren't surviving new vm instances. BTW, I used this youtube video for the oauth2 walkthrough - [this video]
Recommends Nóra · 2016-08 · Stack Overflow · on “Google AppEngine to Fusion Tables with Service Accounts”
See also: Google OAuth2 for python [LINK] (especially the embedded slideshow video) and the live video [this video] for more detailed info on using OAuth2 on Google App Engine.
Recommends Brian Kay Walker · 2018-02 · Stack Overflow · on “Google App Engine oauth2 Callback 404”
In addition to including the : app = webapp2.WSGIApplication( [ ('/', MainHandler), (decorator.callback_path, decorator.callback_handler()), ], debug=True) The @decorator.oauth_required handles the callbacks for you. Check out this video: [this video] You need to create credentials for both localhost development and deployed. And make sure you have checked out: [LINK] Your api imports must be handled like 3rd party imports, details here: [LINK]
Cites sean · 2015-06 · Stack Overflow · on “Google App Engine Python - YouTube API v3 - Insufficient Permission”
I successfully duplicated the Tasks API from this [this video] video, but I am unable to successfully translate this format to using the YouTube API. Here is my .py file: import httplib2 import os import sys import jinja2 import webapp2 import logging import pprint from oauth2client import tools from oauth2client.client import flow_from_clientsecrets from oauth2client.client import OAuth2WebServerFlow from oauth2client.client import AccessTokenRefreshError from oauth2client.tools import argparser, run_flow from oauth2client.appengine import OAuth2Decorator from apiclient.discovery import build from google.appengine.ext.webapp import util from google.appengine.ext.webapp import template decorator