Add Twitter/X to CommonOAuth2Provider

Add Twitter/X to CommonOAuth2Provider
This commit is contained in:
Rob Winch 2025-05-07 15:08:23 -05:00 committed by GitHub
commit ff8b77df29
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 2 deletions

View File

@ -87,6 +87,23 @@ public enum CommonOAuth2Provider {
},
X {
@Override
public Builder getBuilder(String registrationId) {
ClientRegistration.Builder builder = getBuilder(registrationId,
ClientAuthenticationMethod.CLIENT_SECRET_POST, DEFAULT_REDIRECT_URL);
builder.scope("users.read", "tweet.read");
builder.authorizationUri("https://x.com/i/oauth2/authorize");
builder.tokenUri("https://api.x.com/2/oauth2/token");
builder.userInfoUri("https://api.x.com/2/users/me");
builder.userNameAttributeName("username");
builder.clientName("X");
return builder;
}
},
OKTA {
@Override

View File

@ -153,7 +153,7 @@ A `ClientRegistration` can be initially configured using discovery of an OpenID
[[webflux-oauth2-login-common-oauth2-provider]]
== CommonOAuth2Provider
`CommonOAuth2Provider` pre-defines a set of default client properties for a number of well known providers: Google, GitHub, Facebook, and Okta.
`CommonOAuth2Provider` pre-defines a set of default client properties for a number of well known providers: Google, GitHub, Facebook, X, and Okta.
For example, the `authorization-uri`, `token-uri`, and `user-info-uri` do not change often for a Provider.
Therefore, it makes sense to provide default values in order to reduce the required configuration.

View File

@ -153,7 +153,7 @@ You can initially configure a `ClientRegistration` by using discovery of an Open
[[oauth2login-common-oauth2-provider]]
== CommonOAuth2Provider
`CommonOAuth2Provider` pre-defines a set of default client properties for a number of well known providers: Google, GitHub, Facebook, and Okta.
`CommonOAuth2Provider` pre-defines a set of default client properties for a number of well known providers: Google, GitHub, Facebook, X, and Okta.
For example, the `authorization-uri`, `token-uri`, and `user-info-uri` do not change often for a provider.
Therefore, it makes sense to provide default values, to reduce the required configuration.