Skip to content

Commit 9b6aa7f

Browse files
committed
Merge branch 'hotfix/0.5.1'
2 parents c464d82 + c755e00 commit 9b6aa7f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/main/java/io/github/coffeelibs/tinyoauth2client/AuthFlow.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,12 @@ URI buildAuthUri(URI redirectEndpoint, String csrfToken, Set<String> scopes) {
197197
"state", csrfToken, //
198198
"code_challenge", pkce.getChallenge(), //
199199
"code_challenge_method", PKCE.METHOD, //
200-
"redirect_uri", redirectEndpoint.toASCIIString(), //
201-
"scope", String.join(" ", scopes)
200+
"redirect_uri", redirectEndpoint.toASCIIString()
202201
));
202+
203+
if(scopes.size() > 0) {
204+
queryString += "&" + URIUtil.buildQueryString(Map.of("scope" ,String.join(" ", scopes)));
205+
}
203206
return URI.create(authEndpoint.getScheme() + "://" + authEndpoint.getRawAuthority() + authEndpoint.getRawPath() + "?" + queryString);
204207
}
205208

src/test/java/io/github/coffeelibs/tinyoauth2client/AuthFlowTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public void testBuildAuthUri(URI authEndpoint, URI redirectEndpoint, String csrf
180180

181181
public static Stream<Arguments> testBuildAuthUri() {
182182
return Stream.of( //
183-
Arguments.of(URI.create("https://login.example.com/"), URI.create("http://127.0.0.1/callback"), "token", Set.of(), URI.create("https://login.example.com/?state=token&scope&code_challenge=C0D3Ch4ll3ng3&response_type=code&client_id=my-client&code_challenge_method=S256&redirect_uri=http%3A%2F%2F127.0.0.1%2Fcallback")), //
183+
Arguments.of(URI.create("https://login.example.com/"), URI.create("http://127.0.0.1/callback"), "token", Set.of(), URI.create("https://login.example.com/?state=token&code_challenge=C0D3Ch4ll3ng3&response_type=code&client_id=my-client&code_challenge_method=S256&redirect_uri=http%3A%2F%2F127.0.0.1%2Fcallback")), //
184184
Arguments.of(URI.create("https://login.example.com/?foo=bar"), URI.create("http://127.0.0.1/callback"), "token", Set.of(""), URI.create("https://login.example.com/?state=token&scope&code_challenge=C0D3Ch4ll3ng3&response_type=code&client_id=my-client&code_challenge_method=S256&redirect_uri=http%3A%2F%2F127.0.0.1%2Fcallback&foo=bar")), //
185185
Arguments.of(URI.create("https://login.example.com/"), URI.create("http://127.0.0.1/callback"), "t0k3n", Set.of("offline_access"), URI.create("https://login.example.com/?state=t0k3n&scope=offline_access&code_challenge=C0D3Ch4ll3ng3&response_type=code&client_id=my-client&code_challenge_method=S256&redirect_uri=http%3A%2F%2F127.0.0.1%2Fcallback")), //
186186
Arguments.of(URI.create("https://login.example.com/?foo=bar"), URI.create("http://127.0.0.1/callback"), "token", Set.of("offline_access"), URI.create("https://login.example.com/?state=token&scope=offline_access&code_challenge=C0D3Ch4ll3ng3&response_type=code&client_id=my-client&code_challenge_method=S256&redirect_uri=http%3A%2F%2F127.0.0.1%2Fcallback&foo=bar")), //

0 commit comments

Comments
 (0)