Skip to content

Commit

Permalink
specify connection scope with var args
Browse files Browse the repository at this point in the history
  • Loading branch information
lbalmaceda committed Oct 14, 2016
1 parent eb1dab6 commit 57c98dc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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()));
Expand Down

0 comments on commit 57c98dc

Please sign in to comment.