Development of the Flask application (Python3 / Heroku) for the internal use of the company and the successful implementation of Google Login (Oauth2) based on the article brijieshb42 , which uses requests_oauthlib.
The study showed that if I pass the parameter “hd” (hosted domain) in my authorization URL, it should do the trick. For example.
https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=OUR_CLIENT_ID&redirect_uri=https%3A%2F%2FOUR_APP.herokuapp.com%2Fconnect&scope=profile+email&state=STATE & hd = our_google_apps_domain.com & access_type = offline
Based on my understanding, this parameter should provide a client-side restriction and only allow logging in from our Google Apps domains (from the server I will contact after that!) Based on Google Documentation , this mailing list, and these stackoverflow messages: post1 , post2 .
However, although my code generates the authorization URL that I pasted above, I can log in with my personal gmail account (@ gmail.com vs @our apps domain.com).
Can someone shed some light on why this is not working? Or suggest a different approach? Basically, they would prefer to prohibit inactive employees from entering the system.
, brijeshb42 :
OAuth2Session(
OUR_CLIENT_ID,
redirect_uri=https://OUR_APP.herokuapp.com/connect,
scope=['profile', 'email']).authorization_url(
https://accounts.google.com/o/oauth2/auth,
hd='our_google_apps_domain.com',
access_type='offline')
URL- auth, !