Skip to content

Support partial Oauth2TokenResponse #11

Open

Description

@kubukoz

The Spotify API only returns:

  • access_token
  • token_type
  • expires_in
  • refresh_token
  • scope

Activity

  1. kubukoz commented on Dec 22, 2020

    @kubukoz
    MemberAuthor

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

  2. sbrunk commented on Jul 11, 2022

    @sbrunk
    Contributor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions