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

Multiple Errors returned by the SDK have the same "Type" and "Code" #274

Closed
OktaTiberiu opened this issue Sep 16, 2021 · 9 comments
Closed

Comments

@OktaTiberiu
Copy link

Error types and codes are not implemented within the SDK as we have seen multiple errors returning "type":0,"code":0" .

Ex :

  1. AuthorizationException: {"type":0,"code":0,"errorDescription":"Invalid status code 400 Bad Request"}
  2. AuthorizationException: {"type":0,"code":0,"errorDescription":"No refresh token found"}

Other than reading the description field, how can we differentiate between these two errors?

@NikitaAvraimov-okta
Copy link
Contributor

Thank you for your concern, we will take a look how we can make error descriptions more useful.

@NikitaAvraimov-okta
Copy link
Contributor

Internal ref OKTA-435834

@thereallukesimpson
Copy link

@NikitaAvraimov-okta Hi, this feedback was from me. I've been advised by Fei a while ago that the SDK returns this generic "Invalid status code 400 Bad Request" instead of "TYPE_OAUTH_TOKEN_ERROR".

Please confirm whether this fix will address that as it is by far our biggest error. I'm concerned that issues other than token expiry are returning this 400 bad request, which we interpret as an expired token.

@NikitaAvraimov-okta
Copy link
Contributor

@thereallukesimpson "TYPE_OAUTH_TOKEN_ERROR" is what we expect to respond with now

@frett
Copy link
Contributor

frett commented Nov 15, 2021

when refreshing tokens we are also getting the "Invalid status code 400" error instead of a more descriptive TYPE_OAUTH_TOKEN_ERROR error.

I traced the error to the usage of the asJson() function here. The asJson() function throws an error for any response code that is not a 2xx code. The OAuth spec specifies that the token endpoint should return a 400 response code when there is an error, and not a 2xx response.

@thereallukesimpson
Copy link

@thereallukesimpson "TYPE_OAUTH_TOKEN_ERROR" is what we expect to respond with now

Hi @NikitaAvraimov-okta. Is there an upcoming release containing this fix?

@JayNewstrom
Copy link
Contributor

The fix from #293 has been released.

@thereallukesimpson
Copy link

thereallukesimpson commented Jan 12, 2022

Hi @JayNewstrom and @NikitaAvraimov-okta. Can you please confirm both the error type and structure that will now be returned for the other ambiguous error listed above:AuthorizationException: {"type":0,"code":0,"errorDescription":"No refresh token found"}

Also, can you please confirm that the structure of the error for TYPE_OAUTH_TOKEN_ERROR will now be the following, i.e. not nested:

AuthorizationException: {"type":2,"code":0,"errorDescription":"Expired refresh token"}

i.e.

AuthorizationException(
    AuthorizationException.TYPE_OAUTH_TOKEN_ERROR,
    0,
    null,
    "Expired refresh token",
    null,
    null
)

@NikitaAvraimov-okta
Copy link
Contributor

NikitaAvraimov-okta commented Jan 14, 2022

@thereallukesimpson when refresh token is non-existent i.e. null when trying to refresh it exception looks like:
AuthorizationException: {"type":0,"code":0,"errorDescription":"No refresh token found"}
For invalid refresh token you will get
AuthorizationException: {"type":2,"code":2002,"error":"invalid_grant","errorDescription":"The refresh token is invalid or expired."

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

5 participants