我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用django.conf.settings.GOOGLE_CLIENT_ID。
def _verify_google_id_token(request): if 'google_id_token' not in request.POST: raise crypt.AppIdentityError("google_id_token missing.") token = request.POST.get('google_id_token', None) idinfo = client.verify_id_token(token, django_settings.GOOGLE_CLIENT_ID) if idinfo['iss'] not in ['accounts.google.com', 'https://accounts.google.com']: raise crypt.AppIdentityError("Invalid issuer.") return token, idinfo
def get_refreshed_token(token): data = urllib.urlencode({ 'client_id': settings.GOOGLE_CLIENT_ID, 'client_secret': settings.GOOGLE_CLIENT_SECRET, 'refresh_token': token.refresh_token, 'grant_type': 'refresh_token'}) request = urllib2.Request( url='https://accounts.google.com/o/oauth2/token', data=data) request_open = urllib2.urlopen(request) response = request_open.read() request_open.close() tokens = json.loads(response) token.access_token = tokens['access_token'] return token
def get_flow(redirect_url=None): return OAuth2WebServerFlow(client_id=settings.GOOGLE_CLIENT_ID, client_secret=settings.GOOGLE_CLIENT_SECRET, scope='profile email', redirect_uri=redirect_url)