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

feat: support exchanging OTP codes for tokens #438

Merged
merged 1 commit into from
Jan 27, 2023

Conversation

stevehobbsdev
Copy link
Contributor

@stevehobbsdev stevehobbsdev commented Jan 26, 2023

Changes

This adds two methods exchange_email_otp_for_tokens and exchange_sms_otp_for_tokens for completing the email and SMS embedded passwordless flows respectively. This is essentially a missing feature; the SDK already supports starting the flows but provides no affordances to be able to complete them.

Also supports authentication using client assertion.

The Auth0 client must have the "Passwordless OTP" grant enabled (see Passwordless embedded login).

Usage example:

client = Auth0Client.new domain: 'YOUR_AUTH0_DOMAIN', client_id: 'YOUR_CLIENT_ID', client_secret: 'YOUR_CLIENT_SECRET'

# Start passwordless using email..
client.start_passwordless_email_flow 'email@test.com', 'code'

# .. or SMS
client.start_passwordless_sms_flow '+44123456789'

# Once the code has been received, call the appropriate method to exchange the OTP:
# From an email:
result = client.exchange_email_otp_for_tokens 'email@test.com', 'OTP'
# <struct Auth0::AccessToken>

# or from SMS
result = client.exchange_sms_otp_for_tokens '+44123456789', 'OTP'
# <struct Auth0::AccessToken>

References

Closes #422

Testing

Please describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. If this library has unit and/or integration testing, tests should be added for new functionality and existing tests should complete without errors.

  • This change adds unit test coverage
  • This change adds integration test coverage
  • This change has been tested on the latest version of Ruby

Checklist

@stevehobbsdev stevehobbsdev marked this pull request as ready for review January 26, 2023 16:14
@stevehobbsdev stevehobbsdev requested a review from a team as a code owner January 26, 2023 16:14
@stevehobbsdev stevehobbsdev merged commit 8eec6ef into master Jan 27, 2023
@stevehobbsdev stevehobbsdev deleted the feat/exchange-otp branch January 27, 2023 10:06
@stevehobbsdev stevehobbsdev mentioned this pull request Jan 27, 2023
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

Successfully merging this pull request may close these issues.

Support for exchanging OTP for Access Token
2 participants