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

Support partial Oauth2TokenResponse #11

Open
kubukoz opened this issue Dec 22, 2020 · 2 comments
Open

Support partial Oauth2TokenResponse #11

kubukoz opened this issue Dec 22, 2020 · 2 comments

Comments

@kubukoz
Copy link
Member

kubukoz commented Dec 22, 2020

The Spotify API only returns:

  • access_token
  • token_type
  • expires_in
  • refresh_token
  • scope
@kubukoz
Copy link
Member Author

kubukoz commented Dec 22, 2020

I guess this also relates to other types, like UserInfo - sometimes we'll need to support custom codecs.

@sbrunk
Copy link
Contributor

sbrunk commented Jul 11, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants