ClientRegistration.Builder.scopes -> scope

Fixes gh-4663
This commit is contained in:
Joe Grandja 2017-10-19 11:17:19 -04:00
parent 1e891b38ab
commit 1f5edc98d5
2 changed files with 9 additions and 9 deletions

View File

@ -37,7 +37,7 @@ public enum CommonOAuth2Provider {
public Builder getBuilder(String registrationId) {
ClientRegistration.Builder builder = getBuilder(registrationId,
ClientAuthenticationMethod.BASIC, DEFAULT_REDIRECT_URL);
builder.scopes("openid", "profile", "email", "address", "phone");
builder.scope("openid", "profile", "email", "address", "phone");
builder.authorizationUri("https://accounts.google.com/o/oauth2/v2/auth");
builder.tokenUri("https://www.googleapis.com/oauth2/v4/token");
builder.jwkSetUri("https://www.googleapis.com/oauth2/v3/certs");
@ -54,7 +54,7 @@ public enum CommonOAuth2Provider {
public Builder getBuilder(String registrationId) {
ClientRegistration.Builder builder = getBuilder(registrationId,
ClientAuthenticationMethod.BASIC, DEFAULT_REDIRECT_URL);
builder.scopes("user");
builder.scope("user");
builder.authorizationUri("https://github.com/login/oauth/authorize");
builder.tokenUri("https://github.com/login/oauth/access_token");
builder.userInfoUri("https://api.github.com/user");
@ -70,7 +70,7 @@ public enum CommonOAuth2Provider {
public Builder getBuilder(String registrationId) {
ClientRegistration.Builder builder = getBuilder(registrationId,
ClientAuthenticationMethod.POST, DEFAULT_REDIRECT_URL);
builder.scopes("public_profile", "email");
builder.scope("public_profile", "email");
builder.authorizationUri("https://www.facebook.com/v2.8/dialog/oauth");
builder.tokenUri("https://graph.facebook.com/v2.8/oauth/access_token");
builder.userInfoUri("https://graph.facebook.com/me");
@ -86,7 +86,7 @@ public enum CommonOAuth2Provider {
public Builder getBuilder(String registrationId) {
ClientRegistration.Builder builder = getBuilder(registrationId,
ClientAuthenticationMethod.BASIC, DEFAULT_REDIRECT_URL);
builder.scopes("openid", "profile", "email", "address", "phone");
builder.scope("openid", "profile", "email", "address", "phone");
builder.userNameAttributeName(IdTokenClaim.SUB);
builder.clientName("Okta");
return builder;

View File

@ -212,7 +212,7 @@ public class ClientRegistration {
this.authorizationGrantType(clientRegistrationProperties.getAuthorizationGrantType());
this.redirectUri(clientRegistrationProperties.getRedirectUri());
if (!CollectionUtils.isEmpty(clientRegistrationProperties.getScope())) {
this.scopes(clientRegistrationProperties.getScope().toArray(new String[0]));
this.scope(clientRegistrationProperties.getScope().toArray(new String[0]));
}
this.authorizationUri(clientRegistrationProperties.getAuthorizationUri());
this.tokenUri(clientRegistrationProperties.getTokenUri());
@ -230,7 +230,7 @@ public class ClientRegistration {
this.authorizationGrantType(clientRegistration.getAuthorizationGrantType());
this.redirectUri(clientRegistration.getRedirectUri());
if (!CollectionUtils.isEmpty(clientRegistration.getScopes())) {
this.scopes(clientRegistration.getScopes().toArray(new String[0]));
this.scope(clientRegistration.getScopes().toArray(new String[0]));
}
this.authorizationUri(clientRegistration.getProviderDetails().getAuthorizationUri());
this.tokenUri(clientRegistration.getProviderDetails().getTokenUri());
@ -265,10 +265,10 @@ public class ClientRegistration {
return this;
}
public Builder scopes(String... scopes) {
if (scopes != null && scopes.length > 0) {
public Builder scope(String... scope) {
if (scope != null && scope.length > 0) {
this.scopes = Collections.unmodifiableSet(
new LinkedHashSet<>(Arrays.asList(scopes)));
new LinkedHashSet<>(Arrays.asList(scope)));
}
return this;
}