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

Unable to access pending_authentication_token in error response #263

Open
joshpensky opened this issue Feb 29, 2024 · 6 comments
Open

Unable to access pending_authentication_token in error response #263

joshpensky opened this issue Feb 29, 2024 · 6 comments

Comments

@joshpensky
Copy link

joshpensky commented Feb 29, 2024

Hi there!

We are testing out not-so-happy paths in our authentication flow, and found an issue with the password auth flow: https://workos.com/docs/reference/user-management/authentication/password

When the user's email is not verified, we expect to receive a email_verification_required error. However, the handle_error_response method in the WorkOS client doesn't pass along the code or pending_authentication_token fields to the default APIError class:

raise APIError.new(
message: json['message'],
http_status: http_status,
request_id: response['x-request-id'],
)

Could y'all make it so the else case here passes along the code and original error response if available?

Our workaround for now is to drop down to using the REST API via Faraday

@PaulAsjes
Copy link
Contributor

Hi there, thanks for the report. We're looking into this and will report back soon.

@PaulAsjes
Copy link
Contributor

This should now be fixed in v5.0.0!

@vddgil
Copy link

vddgil commented Jul 26, 2024

Hello there,

It's not fixed. When you use the method authenticate_with_password and you get an error code email_verification_required, a WorkOS::APIError exception is raised and this exception doesn't contain the needed data to continue the flow (pending_authentication_token and email_verification_id)

@PaulAsjes Maybe you could re-open this issue?

@sungwon
Copy link

sungwon commented Nov 12, 2024

Hi, I am having the same issue. It is not yet fixed. Could you please re-open?

Also, noting that the error response code 403 indicates that the API key used did not have the correct permissions, which is confusing. Most likely it should be a 400.

@sungwon
Copy link

sungwon commented Nov 12, 2024

I'm currently using a fork of the SDK and added a one-line hack to handle the 403 like a 400 in case this may help others move forward with their integration:
https://github.com/sungwon/workos-ruby/blob/e718dcc539f1a0e11977774cd39fdaf7a07e5f3c/lib/workos/client.rb#L95

@PaulAsjes
Copy link
Contributor

Sorry for the delay here, re-opening so we can fix this.

@PaulAsjes PaulAsjes reopened this Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants