Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make OAuth scope optional #30

Merged
merged 3 commits into from
Feb 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,9 @@ private static TokenInfo post(URI tokenEndpointUri, SSLSocketFactory socketFacto
throw new IllegalStateException("Invalid response from authorization server: no expires_in");
}

// Some OAuth2 authorization servers don't provide scope in this level,
// therefore we don't need to make it mandatory
JsonNode scope = result.get("scope");
if (scope == null) {
throw new IllegalStateException("Invalid response from authorization server: no scope");
}

if (isJWT) {
// try introspect token
Expand All @@ -116,7 +115,7 @@ private static TokenInfo post(URI tokenEndpointUri, SSLSocketFactory socketFacto
}
}

return new TokenInfo(token.asText(), scope.asText(), "undefined", now, now + expiresIn.asLong() * 1000L);
return new TokenInfo(token.asText(), scope != null ? scope.asText() : null, "undefined", now, now + expiresIn.asLong() * 1000L);
}

public static String base64encode(String value) {
Expand Down