带有Python的Google Oauth2.0:如何限制对特定域的访问?

发布于 2021-01-29 16:44:44

我试图了解使用此Python Oauth2.0示例时如何限制对我的应用程序的访问。我见过一些可以将hd =
domain.com添加到authorize_url末尾的地方,但这对我不起作用。

有人可以根据此示例阐明如何限制对我的Flask应用程序的访问吗? https://github.com/mitsuhiko/flask-
oauth/blob/master/example/google.py

关注者
0
被浏览
48
1 个回答
  • 面试哥
    面试哥 2021-01-29
    为面试而生,有面试问题,就找面试哥。

    所以我可以自己回答。在构建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)
    


知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看