prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Patreon login doesn't work/setup is not intuitive
  **Describe the bug**
  While trying to set up the Patreon social integration, I realised that the required fields of Consumer Key and Consumer Secret don't seem to apply to the data that Patreon provides with its API - or at least the terminology is confusing. But outside of that, the default scopes that it seems to be presenting Patreon with upon setup are not part of Patreon's API, and will always error out with an "Invalid Scope" unless manually replaced with the correct ones. If this social integration is working and I'm mistaken, it is missing documentation that would definitely make it easier on new users.
  
  To Reproduce
  Steps to reproduce the behavior:
  
  1. Go to the social integration settings.
  2. Click on the Patreon integration.
  3. Enter the Client ID and Secret into the Key and Secret fields (assuming that's what you're supposed to use)
  4. Get an invalid_scope error when trying to sign in
  
  Expected behavior
  Should allow users to log in via Patreon.
  
  Screenshots
  N/A
  
  Logs
  N/A
  
  Version and Deployment (please complete the following information):
  
  authentik version: 2023.6.1
  Deployment: TrueNAS
  
  
  
  
  
  
  
  
  --- 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/patreon.py`
  Content:
  ```
  1 """Patreon OAuth Views"""
  2 from typing import Any
  3 
  4 from authentik.sources.oauth.clients.oauth2 import UserprofileHeaderAuthClient
  5 from authentik.sources.oauth.models import OAuthSource
  6 from authentik.sources.oauth.types.registry import SourceType, registry
  7 from authentik.sources.oauth.views.callback import OAuthCallback
  8 from authentik.sources.oauth.views.redirect import OAuthRedirect
  9 
  10 
  11 class PatreonOAuthRedirect(OAuthRedirect):
  12     """Patreon OAuth2 Redirect"""
  13 
  14     def get_additional_parameters(self, source: OAuthSource):  # pragma: no cover
  15         return {
  16             "scope": ["openid", "email", "profile"],
  17         }
  18 
  19 
  20 class PatreonOAuthCallback(OAuthCallback):
  21     """Patreon OAuth2 Callback"""
  22 
  23     client_class: UserprofileHeaderAuthClient
  24 
  25     def get_user_id(self, info: dict[str, str]) -> str:
  26         return info.get("data", {}).get("id")
  27 
  28     def get_user_enroll_context(
  29         self,
  30         info: dict[str, Any],
  31     ) -> dict[str, Any]:
  32         return {
  33             "username": info.get("data", {}).get("attributes", {}).get("vanity"),
  34             "email": info.get("data", {}).get("attributes", {}).get("email"),
  35             "name": info.get("data", {}).get("attributes", {}).get("full_name"),
  36         }
  37 
  38 
  39 @registry.register()
  40 class PatreonType(SourceType):
  41     """OpenIDConnect Type definition"""
  42 
  43     callback_view = PatreonOAuthCallback
  44     redirect_view = PatreonOAuthRedirect
  45     name = "Patreon"
  46     slug = "patreon"
  47 
  48     authorization_url = "https://www.patreon.com/oauth2/authorize"
  49     access_token_url = "https://www.patreon.com/api/oauth2/token"  # nosec
  50     profile_url = "https://www.patreon.com/api/oauth2/api/current_user"
  51
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/authentik/sources/oauth/types/patreon.py b/authentik/sources/oauth/types/patreon.py
  --- a/authentik/sources/oauth/types/patreon.py
  +++ b/authentik/sources/oauth/types/patreon.py
  @@ -12,8 +12,9 @@
       """Patreon OAuth2 Redirect"""
   
       def get_additional_parameters(self, source: OAuthSource):  # pragma: no cover
  +        # https://docs.patreon.com/#scopes
           return {
  -            "scope": ["openid", "email", "profile"],
  +            "scope": ["identity", "identity[email]"],
           }
  
verification_info: {"golden_diff": "diff --git a/authentik/sources/oauth/types/patreon.py b/authentik/sources/oauth/types/patreon.py\n--- a/authentik/sources/oauth/types/patreon.py\n+++ b/authentik/sources/oauth/types/patreon.py\n@@ -12,8 +12,9 @@\n     \"\"\"Patreon OAuth2 Redirect\"\"\"\r\n \r\n     def get_additional_parameters(self, source: OAuthSource):  # pragma: no cover\r\n+        # https://docs.patreon.com/#scopes\r\n         return {\r\n-            \"scope\": [\"openid\", \"email\", \"profile\"],\r\n+            \"scope\": [\"identity\", \"identity[email]\"],\r\n         }\n", "issue": "Patreon login doesn't work/setup is not intuitive\n**Describe the bug**\r\nWhile trying to set up the Patreon social integration, I realised that the required fields of Consumer Key and Consumer Secret don't seem to apply to the data that Patreon provides with its API - or at least the terminology is confusing. But outside of that, the default scopes that it seems to be presenting Patreon with upon setup are not part of Patreon's API, and will always error out with an \"Invalid Scope\" unless manually replaced with the correct ones. If this social integration is working and I'm mistaken, it is missing documentation that would definitely make it easier on new users.\r\n\r\nTo Reproduce\r\nSteps to reproduce the behavior:\r\n\r\n1. Go to the social integration settings.\r\n2. Click on the Patreon integration.\r\n3. Enter the Client ID and Secret into the Key and Secret fields (assuming that's what you're supposed to use)\r\n4. Get an invalid_scope error when trying to sign in\r\n\r\nExpected behavior\r\nShould allow users to log in via Patreon.\r\n\r\nScreenshots\r\nN/A\r\n\r\nLogs\r\nN/A\r\n\r\nVersion and Deployment (please complete the following information):\r\n\r\nauthentik version: 2023.6.1\r\nDeployment: TrueNAS\r\n\r\n\r\n\r\n\r\n\r\n\r\n\n", "before_files": [{"content": "\"\"\"Patreon OAuth Views\"\"\"\r\nfrom typing import Any\r\n\r\nfrom authentik.sources.oauth.clients.oauth2 import UserprofileHeaderAuthClient\r\nfrom authentik.sources.oauth.models import OAuthSource\r\nfrom authentik.sources.oauth.types.registry import SourceType, registry\r\nfrom authentik.sources.oauth.views.callback import OAuthCallback\r\nfrom authentik.sources.oauth.views.redirect import OAuthRedirect\r\n\r\n\r\nclass PatreonOAuthRedirect(OAuthRedirect):\r\n    \"\"\"Patreon OAuth2 Redirect\"\"\"\r\n\r\n    def get_additional_parameters(self, source: OAuthSource):  # pragma: no cover\r\n        return {\r\n            \"scope\": [\"openid\", \"email\", \"profile\"],\r\n        }\r\n\r\n\r\nclass PatreonOAuthCallback(OAuthCallback):\r\n    \"\"\"Patreon OAuth2 Callback\"\"\"\r\n\r\n    client_class: UserprofileHeaderAuthClient\r\n\r\n    def get_user_id(self, info: dict[str, str]) -> str:\r\n        return info.get(\"data\", {}).get(\"id\")\r\n\r\n    def get_user_enroll_context(\r\n        self,\r\n        info: dict[str, Any],\r\n    ) -> dict[str, Any]:\r\n        return {\r\n            \"username\": info.get(\"data\", {}).get(\"attributes\", {}).get(\"vanity\"),\r\n            \"email\": info.get(\"data\", {}).get(\"attributes\", {}).get(\"email\"),\r\n            \"name\": info.get(\"data\", {}).get(\"attributes\", {}).get(\"full_name\"),\r\n        }\r\n\r\n\r\n@registry.register()\r\nclass PatreonType(SourceType):\r\n    \"\"\"OpenIDConnect Type definition\"\"\"\r\n\r\n    callback_view = PatreonOAuthCallback\r\n    redirect_view = PatreonOAuthRedirect\r\n    name = \"Patreon\"\r\n    slug = \"patreon\"\r\n\r\n    authorization_url = \"https://www.patreon.com/oauth2/authorize\"\r\n    access_token_url = \"https://www.patreon.com/api/oauth2/token\"  # nosec\r\n    profile_url = \"https://www.patreon.com/api/oauth2/api/current_user\"\r\n", "path": "authentik/sources/oauth/types/patreon.py"}], "after_files": [{"content": "\"\"\"Patreon OAuth Views\"\"\"\r\nfrom typing import Any\r\n\r\nfrom authentik.sources.oauth.clients.oauth2 import UserprofileHeaderAuthClient\r\nfrom authentik.sources.oauth.models import OAuthSource\r\nfrom authentik.sources.oauth.types.registry import SourceType, registry\r\nfrom authentik.sources.oauth.views.callback import OAuthCallback\r\nfrom authentik.sources.oauth.views.redirect import OAuthRedirect\r\n\r\n\r\nclass PatreonOAuthRedirect(OAuthRedirect):\r\n    \"\"\"Patreon OAuth2 Redirect\"\"\"\r\n\r\n    def get_additional_parameters(self, source: OAuthSource):  # pragma: no cover\r\n        # https://docs.patreon.com/#scopes\r\n        return {\r\n            \"scope\": [\"identity\", \"identity[email]\"],\r\n        }\r\n\r\n\r\nclass PatreonOAuthCallback(OAuthCallback):\r\n    \"\"\"Patreon OAuth2 Callback\"\"\"\r\n\r\n    client_class: UserprofileHeaderAuthClient\r\n\r\n    def get_user_id(self, info: dict[str, str]) -> str:\r\n        return info.get(\"data\", {}).get(\"id\")\r\n\r\n    def get_user_enroll_context(\r\n        self,\r\n        info: dict[str, Any],\r\n    ) -> dict[str, Any]:\r\n        return {\r\n            \"username\": info.get(\"data\", {}).get(\"attributes\", {}).get(\"vanity\"),\r\n            \"email\": info.get(\"data\", {}).get(\"attributes\", {}).get(\"email\"),\r\n            \"name\": info.get(\"data\", {}).get(\"attributes\", {}).get(\"full_name\"),\r\n        }\r\n\r\n\r\n@registry.register()\r\nclass PatreonType(SourceType):\r\n    \"\"\"OpenIDConnect Type definition\"\"\"\r\n\r\n    callback_view = PatreonOAuthCallback\r\n    redirect_view = PatreonOAuthRedirect\r\n    name = \"Patreon\"\r\n    slug = \"patreon\"\r\n\r\n    authorization_url = \"https://www.patreon.com/oauth2/authorize\"\r\n    access_token_url = \"https://www.patreon.com/api/oauth2/token\"  # nosec\r\n    profile_url = \"https://www.patreon.com/api/oauth2/api/current_user\"\r\n", "path": "authentik/sources/oauth/types/patreon.py"}]}