diff --git a/README.md b/README.md index 5a33eaa24..395ec3ad8 100644 --- a/README.md +++ b/README.md @@ -387,7 +387,7 @@ WebAuthProvider.init(account) ```java WebAuthProvider.init(account) - .withConnectionScope("email profile calendar:read") + .withConnectionScope("email", "profile", "calendar:read") .start(MainActivity.this, authCallback, WEB_REQ_CODE); ``` diff --git a/auth0/src/main/java/com/auth0/android/provider/WebAuthProvider.java b/auth0/src/main/java/com/auth0/android/provider/WebAuthProvider.java index 57fe9353d..86817de72 100644 --- a/auth0/src/main/java/com/auth0/android/provider/WebAuthProvider.java +++ b/auth0/src/main/java/com/auth0/android/provider/WebAuthProvider.java @@ -175,8 +175,15 @@ public Builder withScope(@NonNull String scope) { * @param connectionScope to request. * @return the current builder instance */ - public Builder withConnectionScope(@NonNull String connectionScope) { - this.connectionScope = connectionScope; + public Builder withConnectionScope(@NonNull String... connectionScope) { + StringBuilder sb = new StringBuilder(); + for (String s : connectionScope) { + sb.append(s.trim()).append(","); + } + if (sb.length() > 0) { + sb.deleteCharAt(sb.length() - 1); + this.connectionScope = sb.toString(); + } return this; } diff --git a/auth0/src/test/java/com/auth0/android/provider/WebAuthProviderTest.java b/auth0/src/test/java/com/auth0/android/provider/WebAuthProviderTest.java index cc0b73cdd..2807543ee 100644 --- a/auth0/src/test/java/com/auth0/android/provider/WebAuthProviderTest.java +++ b/auth0/src/test/java/com/auth0/android/provider/WebAuthProviderTest.java @@ -198,7 +198,7 @@ public void shouldBuildAuthorizeURI() throws Exception { .withConnection("my-connection") .withState("a-state") .withScope("super_scope") - .withConnectionScope("super_connection_scope") + .withConnectionScope("first_connection_scope", "second_connection_scope") .withParameters(parameters) .start(activity, callback, REQUEST_CODE); @@ -214,7 +214,7 @@ public void shouldBuildAuthorizeURI() throws Exception { assertThat(intentCaptor.getValue().getData(), hasParamWithValue("connection", "my-connection")); assertThat(intentCaptor.getValue().getData(), hasParamWithValue("state", "a-state")); assertThat(intentCaptor.getValue().getData(), hasParamWithValue("scope", "super_scope")); - assertThat(intentCaptor.getValue().getData(), hasParamWithValue("connection_scope", "super_connection_scope")); + assertThat(intentCaptor.getValue().getData(), hasParamWithValue("connection_scope", "first_connection_scope,second_connection_scope")); assertThat(intentCaptor.getValue().getData(), hasParamWithValue("custom_param_1", "custom_value_1")); assertThat(intentCaptor.getValue().getData(), hasParamWithValue("custom_param_2", "custom_value_2")); assertThat(intentCaptor.getValue().getData(), hasParamWithValue("client_id", account.getClientId()));