polyvariant / polyvariant/sttp-oauth2
PasswordGrant fails to decode user_name
Open
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 80
- Forks
- 23
- PR merge metrics
- No merged PRs in 30d
Description
Exception in thread "main" 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$5(PasswordGrantProvider.scala:30)
at cats.syntax.EitherOps$.leftMap$extension(either.scala:193)
at com.ocadotechnology.sttp.oauth2.PasswordGrantProvider$.$anonfun$apply$4(PasswordGrantProvider.scala:30)
at sttp.client3.monad.IdMonad$.map(IdMonad.scala:8)
at sttp.monad.syntax$MonadErrorOps.map(MonadError.scala:60)
at com.ocadotechnology.sttp.oauth2.PasswordGrantProvider$.$anonfun$apply$2(PasswordGrantProvider.scala:30)
at sttp.monad.syntax$MonadErrorOps.flatMap(MonadError.scala:61)
at com.ocadotechnology.sttp.oauth2.PasswordGrantProvider$.$anonfun$apply$1(PasswordGrantProvider.scala:31)
at OauthTest$.main(OauthTest.scala:18)
at OauthTest.main(OauthTest.scala)
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)
at sttp.client3.monad.IdMonad$.map(IdMonad.scala:8)
at sttp.monad.syntax$MonadErrorOps.map(MonadError.scala:60)
at sttp.client3.internal.BodyFromResponseAs.doApply(BodyFromResponseAs.scala:24)
at sttp.client3.internal.BodyFromResponseAs.$anonfun$apply$1(BodyFromResponseAs.scala:14)
at sttp.monad.syntax$MonadErrorOps.map(MonadError.scala:60)
at sttp.client3.internal.BodyFromResponseAs.apply(BodyFromResponseAs.scala:14)
at sttp.client3.HttpURLConnectionBackend.readResponse(HttpURLConnectionBackend.scala:245)
at sttp.client3.HttpURLConnectionBackend.$anonfun$send$1(HttpURLConnectionBackend.scala:56)
at scala.util.Try$.apply(Try.scala:209)
at sttp.monad.MonadError.handleError(MonadError.scala:24)
at sttp.monad.MonadError.handleError$(MonadError.scala:23)
at sttp.client3.monad.IdMonad$.handleError(IdMonad.scala:6)
at sttp.client3.SttpClientException$.adjustExceptions(SttpClientException.scala:58)
at sttp.client3.HttpURLConnectionBackend.adjustExceptions(HttpURLConnectionBackend.scala:295)
at sttp.client3.HttpURLConnectionBackend.send(HttpURLConnectionBackend.scala:30)
at sttp.client3.HttpURLConnectionBackend.send(HttpURLConnectionBackend.scala:22)
at sttp.client3.FollowRedirectsBackend.sendWithCounter(FollowRedirectsBackend.scala:29)
at sttp.client3.FollowRedirectsBackend.send(FollowRedirectsBackend.scala:24)
at com.ocadotechnology.sttp.oauth2.PasswordGrant$.$anonfun$requestToken$1(PasswordGrant.scala:40)
at sttp.monad.syntax$MonadErrorOps.map(MonadError.scala:60)
at com.ocadotechnology.sttp.oauth2.PasswordGrant$.requestToken(PasswordGrant.scala:42)
at com.ocadotechnology.sttp.oauth2.PasswordGrantProvider$.$anonfun$apply$3(PasswordGrantProvider.scala:29)
... 6 more
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)
... 30 more
Originally posted by @reoxu in https://github.com/ocadotechnology/sttp-oauth2/issues/335#issuecomment-1376877020
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the failing stack-trace locations in PasswordGrantProvider.scala and PasswordGrant.scala, then inspect common.scala where the response is deserialized. Reproduce the reported PasswordGrant call using the OauthTest entry point and trace the response fields. Done means the call no longer raises the reported missing-field deserialization error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- api, authentication
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100