We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
2023.10.6 - "Please select a username" after Azure AD login
**Describe your question/**

Is it now a expected behavior in 2023.10.6 version to ask every user for username input after logging in with azure ad?
![image](https://github.com/goauthentik/authentik/assets/7706996/7c35f530-62a2-4afd-92aa-c290ad221c5f)

In previous versions it was simply authenticating without any prompt, using email address from Azure AD as username.

Now it expects user to input username (and it leads to duplicated accounts, because users with mail as username already exist), and if you enter already existing mail as username it shows error:
![image](https://github.com/goauthentik/authentik/assets/7706996/a8aaaf90-b309-425c-92a1-174739d01fc6)

I think it can be related to this fix:
https://github.com/goauthentik/authentik/pull/7970

Is it possible somehow to set this username automatically, or revert back to using email address so old user accounts will work again?

**Version and Deployment (please complete the following information):**

-   authentik version: 2023.10.6
-   Deployment: helm



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `authentik/sources/oauth/types/azure_ad.py`
Content:
```
1 """AzureAD OAuth2 Views"""
2 from typing import Any
3 
4 from structlog.stdlib import get_logger
5 
6 from authentik.sources.oauth.clients.oauth2 import UserprofileHeaderAuthClient
7 from authentik.sources.oauth.types.oidc import OpenIDConnectOAuth2Callback
8 from authentik.sources.oauth.types.registry import SourceType, registry
9 from authentik.sources.oauth.views.redirect import OAuthRedirect
10 
11 LOGGER = get_logger()
12 
13 
14 class AzureADOAuthRedirect(OAuthRedirect):
15     """Azure AD OAuth2 Redirect"""
16 
17     def get_additional_parameters(self, source):  # pragma: no cover
18         return {
19             "scope": ["openid", "https://graph.microsoft.com/User.Read"],
20         }
21 
22 
23 class AzureADOAuthCallback(OpenIDConnectOAuth2Callback):
24     """AzureAD OAuth2 Callback"""
25 
26     client_class = UserprofileHeaderAuthClient
27 
28     def get_user_enroll_context(
29         self,
30         info: dict[str, Any],
31     ) -> dict[str, Any]:
32         mail = info.get("mail", None) or info.get("otherMails", [None])[0]
33         return {
34             "username": info.get("userPrincipalName"),
35             "email": mail,
36             "name": info.get("displayName"),
37         }
38 
39 
40 @registry.register()
41 class AzureADType(SourceType):
42     """Azure AD Type definition"""
43 
44     callback_view = AzureADOAuthCallback
45     redirect_view = AzureADOAuthRedirect
46     verbose_name = "Azure AD"
47     name = "azuread"
48 
49     urls_customizable = True
50 
51     authorization_url = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize"
52     access_token_url = "https://login.microsoftonline.com/common/oauth2/v2.0/token"  # nosec
53     profile_url = "https://login.microsoftonline.com/common/openid/userinfo"
54     oidc_well_known_url = (
55         "https://login.microsoftonline.com/common/.well-known/openid-configuration"
56     )
57     oidc_jwks_url = "https://login.microsoftonline.com/common/discovery/keys"
58
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/authentik/sources/oauth/types/azure_ad.py b/authentik/sources/oauth/types/azure_ad.py
--- a/authentik/sources/oauth/types/azure_ad.py
+++ b/authentik/sources/oauth/types/azure_ad.py
@@ -50,7 +50,7 @@
 
     authorization_url = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize"
     access_token_url = "https://login.microsoftonline.com/common/oauth2/v2.0/token"  # nosec
-    profile_url = "https://login.microsoftonline.com/common/openid/userinfo"
+    profile_url = "https://graph.microsoft.com/v1.0/me"
     oidc_well_known_url = (
         "https://login.microsoftonline.com/common/.well-known/openid-configuration"
     )

{"golden_diff": "diff --git a/authentik/sources/oauth/types/azure_ad.py b/authentik/sources/oauth/types/azure_ad.py\n--- a/authentik/sources/oauth/types/azure_ad.py\n+++ b/authentik/sources/oauth/types/azure_ad.py\n@@ -50,7 +50,7 @@\n \n     authorization_url = \"https://login.microsoftonline.com/common/oauth2/v2.0/authorize\"\n     access_token_url = \"https://login.microsoftonline.com/common/oauth2/v2.0/token\"  # nosec\n-    profile_url = \"https://login.microsoftonline.com/common/openid/userinfo\"\n+    profile_url = \"https://graph.microsoft.com/v1.0/me\"\n     oidc_well_known_url = (\n         \"https://login.microsoftonline.com/common/.well-known/openid-configuration\"\n     )\n", "issue": "2023.10.6 - \"Please select a username\" after Azure AD login\n**Describe your question/**\r\n\r\nIs it now a expected behavior in 2023.10.6 version to ask every user for username input after logging in with azure ad?\r\n![image](https://github.com/goauthentik/authentik/assets/7706996/7c35f530-62a2-4afd-92aa-c290ad221c5f)\r\n\r\nIn previous versions it was simply authenticating without any prompt, using email address from Azure AD as username.\r\n\r\nNow it expects user to input username (and it leads to duplicated accounts, because users with mail as username already exist), and if you enter already existing mail as username it shows error:\r\n![image](https://github.com/goauthentik/authentik/assets/7706996/a8aaaf90-b309-425c-92a1-174739d01fc6)\r\n\r\nI think it can be related to this fix:\r\nhttps://github.com/goauthentik/authentik/pull/7970\r\n\r\nIs it possible somehow to set this username automatically, or revert back to using email address so old user accounts will work again?\r\n\r\n**Version and Deployment (please complete the following information):**\r\n\r\n-   authentik version: 2023.10.6\r\n-   Deployment: helm\r\n\r\n\n", "before_files": [{"content": "\"\"\"AzureAD OAuth2 Views\"\"\"\nfrom typing import Any\n\nfrom structlog.stdlib import get_logger\n\nfrom authentik.sources.oauth.clients.oauth2 import UserprofileHeaderAuthClient\nfrom authentik.sources.oauth.types.oidc import OpenIDConnectOAuth2Callback\nfrom authentik.sources.oauth.types.registry import SourceType, registry\nfrom authentik.sources.oauth.views.redirect import OAuthRedirect\n\nLOGGER = get_logger()\n\n\nclass AzureADOAuthRedirect(OAuthRedirect):\n    \"\"\"Azure AD OAuth2 Redirect\"\"\"\n\n    def get_additional_parameters(self, source):  # pragma: no cover\n        return {\n            \"scope\": [\"openid\", \"https://graph.microsoft.com/User.Read\"],\n        }\n\n\nclass AzureADOAuthCallback(OpenIDConnectOAuth2Callback):\n    \"\"\"AzureAD OAuth2 Callback\"\"\"\n\n    client_class = UserprofileHeaderAuthClient\n\n    def get_user_enroll_context(\n        self,\n        info: dict[str, Any],\n    ) -> dict[str, Any]:\n        mail = info.get(\"mail\", None) or info.get(\"otherMails\", [None])[0]\n        return {\n            \"username\": info.get(\"userPrincipalName\"),\n            \"email\": mail,\n            \"name\": info.get(\"displayName\"),\n        }\n\n\n@registry.register()\nclass AzureADType(SourceType):\n    \"\"\"Azure AD Type definition\"\"\"\n\n    callback_view = AzureADOAuthCallback\n    redirect_view = AzureADOAuthRedirect\n    verbose_name = \"Azure AD\"\n    name = \"azuread\"\n\n    urls_customizable = True\n\n    authorization_url = \"https://login.microsoftonline.com/common/oauth2/v2.0/authorize\"\n    access_token_url = \"https://login.microsoftonline.com/common/oauth2/v2.0/token\"  # nosec\n    profile_url = \"https://login.microsoftonline.com/common/openid/userinfo\"\n    oidc_well_known_url = (\n        \"https://login.microsoftonline.com/common/.well-known/openid-configuration\"\n    )\n    oidc_jwks_url = \"https://login.microsoftonline.com/common/discovery/keys\"\n", "path": "authentik/sources/oauth/types/azure_ad.py"}], "after_files": [{"content": "\"\"\"AzureAD OAuth2 Views\"\"\"\nfrom typing import Any\n\nfrom structlog.stdlib import get_logger\n\nfrom authentik.sources.oauth.clients.oauth2 import UserprofileHeaderAuthClient\nfrom authentik.sources.oauth.types.oidc import OpenIDConnectOAuth2Callback\nfrom authentik.sources.oauth.types.registry import SourceType, registry\nfrom authentik.sources.oauth.views.redirect import OAuthRedirect\n\nLOGGER = get_logger()\n\n\nclass AzureADOAuthRedirect(OAuthRedirect):\n    \"\"\"Azure AD OAuth2 Redirect\"\"\"\n\n    def get_additional_parameters(self, source):  # pragma: no cover\n        return {\n            \"scope\": [\"openid\", \"https://graph.microsoft.com/User.Read\"],\n        }\n\n\nclass AzureADOAuthCallback(OpenIDConnectOAuth2Callback):\n    \"\"\"AzureAD OAuth2 Callback\"\"\"\n\n    client_class = UserprofileHeaderAuthClient\n\n    def get_user_enroll_context(\n        self,\n        info: dict[str, Any],\n    ) -> dict[str, Any]:\n        mail = info.get(\"mail\", None) or info.get(\"otherMails\", [None])[0]\n        return {\n            \"username\": info.get(\"userPrincipalName\"),\n            \"email\": mail,\n            \"name\": info.get(\"displayName\"),\n        }\n\n\n@registry.register()\nclass AzureADType(SourceType):\n    \"\"\"Azure AD Type definition\"\"\"\n\n    callback_view = AzureADOAuthCallback\n    redirect_view = AzureADOAuthRedirect\n    verbose_name = \"Azure AD\"\n    name = \"azuread\"\n\n    urls_customizable = True\n\n    authorization_url = \"https://login.microsoftonline.com/common/oauth2/v2.0/authorize\"\n    access_token_url = \"https://login.microsoftonline.com/common/oauth2/v2.0/token\"  # nosec\n    profile_url = \"https://graph.microsoft.com/v1.0/me\"\n    oidc_well_known_url = (\n        \"https://login.microsoftonline.com/common/.well-known/openid-configuration\"\n    )\n    oidc_jwks_url = \"https://login.microsoftonline.com/common/discovery/keys\"\n", "path": "authentik/sources/oauth/types/azure_ad.py"}]}