Support partial Oauth2TokenResponse
The Spotify API only returns:
- access_token
- token_type
- expires_in
- refresh_token
- scope
I guess this also relates to other types, like UserInfo - sometimes we'll need to support custom codecs.
I'm trying to use PasswordGrant against a Keycloak instance, which causes a deserialization error:
com.ocadotechnology.sttp.oauth2.common$OAuth2Exception: Client call resulted in error (200): Missing required field: DownField(user_name)
at com.ocadotechnology.sttp.oauth2.PasswordGrantProvider$.$anonfun$apply$3(PasswordGrantProvider.scala:26)
at cats.syntax.EitherOps$.leftMap$extension(either.scala:172)
at com.ocadotechnology.sttp.oauth2.PasswordGrantProvider$.$anonfun$apply$2(PasswordGrantProvider.scala:26)
...
Caused by: com.ocadotechnology.sttp.oauth2.common$Error$HttpClientError: Client call resulted in error (200): Missing required field: DownField(user_name)
at com.ocadotechnology.sttp.oauth2.common$.$anonfun$responseWithCommonError$1(common.scala:103)
at sttp.client3.MappedResponseAs.$anonfun$mapWithMetadata$1(ResponseAs.scala:91)
at sttp.client3.internal.BodyFromResponseAs.$anonfun$doApply$2(BodyFromResponseAs.scala:24)
...
Caused by: sttp.client3.DeserializationException: Missing required field: DownField(user_name)
at sttp.client3.ResponseAs$.$anonfun$deserializeWithError$1(ResponseAs.scala:201)
at sttp.client3.ResponseAs$.$anonfun$deserializeRightWithError$1(ResponseAs.scala:180)
at sttp.client3.MappedResponseAs.$anonfun$mapWithMetadata$1(ResponseAs.scala:91)
The token endpoint essentially returns the fields in OAuth2TokenResponse (plus a few others), but not the extra ones from ExtendedOAuth2TokenResponse, so I guess that's the issue here because PasswordGrant still expects an ExtendedOAuth2TokenResponse.
I'm not too familiar with the codebase yet. Would it be possible to parameterize PasswordGrant to expect a custom token response like it's already done for AuthorizationCodeGrant in #104?