diff --git a/web/pgadmin/authenticate/oauth2.py b/web/pgadmin/authenticate/oauth2.py
index 935d110a7..7134f3ea2 100644
--- a/web/pgadmin/authenticate/oauth2.py
+++ b/web/pgadmin/authenticate/oauth2.py
@@ -119,7 +119,14 @@ class OAuth2Authentication(BaseAuthentication):
 
     def login(self, form):
         profile = self.get_user_profile()
-        if 'email' not in profile or not profile['email']:
+        email = None
+        if 'email' in profile or 'mail' in profile:
+            if profile['email']:
+                email = profile['email']
+            else:
+                email = profile['mail']
+
+        if not email or email == '':
             current_app.logger.exception(
                 "An email id is required to login into pgAdmin. "
                 "Please update your Oauth2 profile."
@@ -128,10 +135,10 @@ class OAuth2Authentication(BaseAuthentication):
                 "An email id is required to login into pgAdmin. "
                 "Please update your Oauth2 profile.")
 
-        user, msg = self.__auto_create_user(profile)
+        user, msg = self.__auto_create_user(email)
         if user:
             user = db.session.query(User).filter_by(
-                username=profile['email'], auth_source=OAUTH2).first()
+                username=email, auth_source=OAUTH2).first()
             current_app.login_manager.logout_view = \
                 OAuth2Authentication.LOGOUT_VIEW
             return login_user(user), None
@@ -161,17 +168,17 @@ class OAuth2Authentication(BaseAuthentication):
         return False, self.oauth2_clients[
             self.oauth2_current_client].authorize_redirect(redirect_url)
 
-    def __auto_create_user(self, resp):
+    def __auto_create_user(self, email):
         if config.OAUTH2_AUTO_CREATE_USER:
-            user = User.query.filter_by(username=resp['email'],
+            user = User.query.filter_by(username=email,
                                         auth_source=OAUTH2).first()
             if not user:
                 return create_user({
-                    'username': resp['email'],
-                    'email': resp['email'],
+                    'username': email,
+                    'email': email,
                     'role': 2,
                     'active': True,
                     'auth_source': OAUTH2
                 })
 
-        return True, {'username': resp['email']}
+        return True, {'username': email}
