I'm setting up a web server that uses Twitch authorization code flow to login a user using the authorization code flow.
The authorization step already works, but jaxson throws an exception during the step where it retrieves the token from Twitch. Digging through the oauth2 security code it looks like jaxson parses the scope as a string, but Twitch returns the scope as an array of strings causing jaxson to throw. I'm thinking maybe I could override the jaxson parser, but I'm not sure how to go about doing that.
This is what the token return from Twitch looks like:
{
"access_token": <access-token>,
"refresh_token": <refresh-token>,
"expires_in": 3600,
"scope": ["viewing_activity_read"],
"token_type": "bearer"
}
The scope being an array is causing the problem at this point in OAuth2AccessTokenResponseHttpMessageConverter at this.jsonMessageConverter.read:
@Override
protected OAuth2AccessTokenResponse readInternal(Class<? extends OAuth2AccessTokenResponse> clazz, HttpInputMessage inputMessage)
throws IOException, HttpMessageNotReadableException {
try {
@SuppressWarnings("unchecked")
Map<String, String> tokenResponseParameters = (Map<String, String>) this.jsonMessageConverter.read(
PARAMETERIZED_RESPONSE_TYPE.getType(), null, inputMessage);
return this.tokenResponseConverter.convert(tokenResponseParameters);
} catch (Exception ex) {
throw new HttpMessageNotReadableException("An error occurred reading the OAuth 2.0 Access Token Response: " +
ex.getMessage(), ex, inputMessage);
}
}
Thanks!