Google Login tracking with user's new email address

I’m in the beginning stages of designing an app for my school. My school uses GSuite, so I’d prefer to run all user authentication through the Google Login feature baked into Anvil. However, I’m not sure what my best options are in relation to handling Gmail email address changes by our teachers.

Since each user will have info written to a database that needs to be accessed by them at a later date, what is the best way to handle teacher janedoe@myschool.org getting married and changing her name such that her address gets updated to janesmith@myschool.org?

Does Anvil handle the Google Login based solely on the primaryEmail field within Google’s API? Or does Anvil’s login process map the Google Login email address to Google’s immutable user “id” field behind the scenes? And if so, is there a way to capture that “id” to do my database lookups for information related to that user? Or am I going to have to write my own code to handle the calls to Google’s AdminDirectory API?

Thanks so much.

Doug

2 Likes

For anyone else dealing with this, I got it going by following the Google Integration instructions from

and then called the oauth2 endpoint shown below to pull the Google ID for the user.

access_token=anvil.google.auth.get_user_access_token()

userinfo=anvil.http.request("https://www.googleapis.com/oauth2/v2/userinfo",json=True,headers={'Authorization':'Bearer '+access_token})

thisuserID=userinfo['id']
2 Likes