2013-12-09 1 views
1

이 Python Oauth2.0 예제를 사용할 때 내 응용 프로그램에 대한 액세스를 제한하는 방법을 이해하려고합니다. authorize_url의 끝 부분에 hd = domain.com을 추가 할 수있는 곳을 보았지만 저에게는 적합하지 않습니다.Google Oauth2.0 with Python : 특정 도메인에 대한 액세스를 어떻게 제한합니까?

누구든지이 예제를 기반으로 내 플라스크 응용 프로그램에 대한 액세스를 제한하는 방법에 대해 설명해 줄 수 있습니까? https://github.com/mitsuhiko/flask-oauth/blob/master/example/google.py

답변

2

그래서 직접 대답 할 수 있습니다. 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)    
관련 문제