Browse Source

Add Twitter/X to CommonOAuth2Provider

Add Twitter/X to CommonOAuth2Provider
pull/17073/head
Rob Winch 9 months ago committed by GitHub
parent
commit
ff8b77df29
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 17
      config/src/main/java/org/springframework/security/config/oauth2/client/CommonOAuth2Provider.java
  2. 2
      docs/modules/ROOT/pages/reactive/oauth2/login/core.adoc
  3. 2
      docs/modules/ROOT/pages/servlet/oauth2/login/core.adoc

17
config/src/main/java/org/springframework/security/config/oauth2/client/CommonOAuth2Provider.java

@ -87,6 +87,23 @@ public enum CommonOAuth2Provider { @@ -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

2
docs/modules/ROOT/pages/reactive/oauth2/login/core.adoc

@ -153,7 +153,7 @@ A `ClientRegistration` can be initially configured using discovery of an OpenID @@ -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.

2
docs/modules/ROOT/pages/servlet/oauth2/login/core.adoc

@ -153,7 +153,7 @@ You can initially configure a `ClientRegistration` by using discovery of an Open @@ -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.

Loading…
Cancel
Save