Skip to content

Commit

Permalink
Remove redundant scope parameter
Browse files Browse the repository at this point in the history
According to https://www.rfc-editor.org/rfc/rfc6749#section-4.1.3 scope
parameter in the get token request is actually redundant as it was
already provided in the authorization request. Refresh token request on
the other hand should still provide it.
  • Loading branch information
lukasz-walkiewicz authored and kokosing committed Dec 15, 2022
1 parent 5b37085 commit 4bf5d5e
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import com.nimbusds.oauth2.sdk.AccessTokenResponse;
import com.nimbusds.oauth2.sdk.AuthorizationCode;
import com.nimbusds.oauth2.sdk.AuthorizationCodeGrant;
import com.nimbusds.oauth2.sdk.AuthorizationGrant;
import com.nimbusds.oauth2.sdk.AuthorizationRequest;
import com.nimbusds.oauth2.sdk.ParseException;
import com.nimbusds.oauth2.sdk.RefreshTokenGrant;
Expand Down Expand Up @@ -347,19 +346,19 @@ private String hashNonce(String nonce)
private <T extends AccessTokenResponse> T getTokenResponse(String code, URI callbackUri, NimbusAirliftHttpClient.Parser<T> parser)
throws ChallengeFailedException
{
return getTokenResponse(new AuthorizationCodeGrant(new AuthorizationCode(code), callbackUri), parser);
return getTokenResponse(new TokenRequest(tokenUrl, clientAuth, new AuthorizationCodeGrant(new AuthorizationCode(code), callbackUri)), parser);
}

private <T extends AccessTokenResponse> T getTokenResponse(String refreshToken, NimbusAirliftHttpClient.Parser<T> parser)
throws ChallengeFailedException
{
return getTokenResponse(new RefreshTokenGrant(new RefreshToken(refreshToken)), parser);
return getTokenResponse(new TokenRequest(tokenUrl, clientAuth, new RefreshTokenGrant(new RefreshToken(refreshToken)), scope), parser);
}

private <T extends AccessTokenResponse> T getTokenResponse(AuthorizationGrant authorizationGrant, NimbusAirliftHttpClient.Parser<T> parser)
private <T extends AccessTokenResponse> T getTokenResponse(TokenRequest tokenRequest, NimbusAirliftHttpClient.Parser<T> parser)
throws ChallengeFailedException
{
T tokenResponse = httpClient.execute(new TokenRequest(tokenUrl, clientAuth, authorizationGrant, scope), parser);
T tokenResponse = httpClient.execute(tokenRequest, parser);
if (!tokenResponse.indicatesSuccess()) {
throw new ChallengeFailedException("Error while fetching access token: " + tokenResponse.toErrorResponse().toJSONObject());
}
Expand Down

0 comments on commit 4bf5d5e

Please sign in to comment.