Skip to content

OAuth2 Third-Party Login

Note

Third-party login will automatically register an account using the user's email (emails with the same address will be considered the same account)

This account is the same as a registered account and can also set a password through the forgot password feature

Register OAuth2 on Third-Party Platforms

GitHub

  • Please first create an OAuth App, then obtain the Client ID and Client Secret

Reference: Creating an OAuth App

Linux Do

  • Create an application at Linux Do Connect to obtain Client ID and Client Secret
  • Linux Do returns a user ID instead of an email, so you need to enable the Email Format feature

Authentik

Configure OAuth2 in Admin Backend

oauth2

Configuration Fields

FieldDescription
NameOAuth2 provider name, displayed on the login page
Client IDOAuth2 application ID
Client SecretOAuth2 application secret
Authorization URLOAuth2 authorization endpoint
Access Token URLEndpoint to obtain Access Token
Access Token Params FormatToken request format: json or urlencoded
User Info URLEndpoint to get user information
User Email KeyKey for email field in user info, supports JSONPath (e.g., $[0].email)
Redirect URLOAuth2 callback URL
ScopeOAuth2 permission scope

Email Format Transformation

When OAuth2 returns a non-standard email format (e.g., returns a user ID), you can enable the Email Format feature.

FieldDescription
Enable Email FormatEnable email format transformation
Email Regex PatternRegular expression to match the original value, use capture groups ()
Replace TemplateReplacement template, use $1, $2, etc. to reference capture groups

Examples:

ScenarioOriginal ValueRegex PatternReplace TemplateResult
ID to Email12345^(.+)$[email protected][email protected]
Change Domain[email protected]^(.+)@old\.com$[email protected][email protected]
Extract Username[email protected]^(.+)@.*$[email protected][email protected]

Email Address Allow List

When enabled, only emails from specified domains can login.

Test User Login Page

oauth2 login

Based on MIT license