diff --git a/backend/open_webui/utils/oauth.py b/backend/open_webui/utils/oauth.py index 131c35800e..105f7c2fab 100644 --- a/backend/open_webui/utils/oauth.py +++ b/backend/open_webui/utils/oauth.py @@ -355,7 +355,11 @@ class OAuthManager: log.warning(f"OAuth callback error: {e}") raise HTTPException(400, detail=ERROR_MESSAGES.INVALID_CRED) user_data: UserInfo = token.get("userinfo") - if not user_data or auth_manager_config.OAUTH_EMAIL_CLAIM not in user_data: + if ( + (not user_data) or + (auth_manager_config.OAUTH_EMAIL_CLAIM not in user_data) or + (auth_manager_config.OAUTH_USERNAME_CLAIM not in user_data) + ): user_data: UserInfo = await client.userinfo(token=token) if not user_data: log.warning(f"OAuth callback failed, user data is missing: {token}")