【问题标题】:Google Oauth2.0 with Python: How do I limit access to a specific domain?带有 Python 的 Google Oauth2.0:如何限制对特定域的访问?
【发布时间】:2013-12-27 06:19:28
【问题描述】:
【问题讨论】:
标签:
python
google-api
oauth-2.0
flask
【解决方案1】:
所以我可以自己回答这个问题。在构建 google 对象时,应该添加“hd”参数。
google = oauth.remote_app('google',
base_url='https://www.google.com/accounts/',
authorize_url='https://accounts.google.com/o/oauth2/auth',
request_token_url=None,
request_token_params={'scope': 'https://www.googleapis.com/auth/userinfo.email',
'response_type': 'code',
'hd':'domain.com'},
access_token_url='https://accounts.google.com/o/oauth2/token',
access_token_method='POST',
access_token_params={'grant_type': 'authorization_code'},
consumer_key=GOOGLE_CLIENT_ID,
consumer_secret=GOOGLE_CLIENT_SECRET)