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

Get access to Auth0 instance from Auth0Provider #950

Open
5 tasks done
bednar opened this issue Aug 12, 2024 · 6 comments
Open
5 tasks done

Get access to Auth0 instance from Auth0Provider #950

bednar opened this issue Aug 12, 2024 · 6 comments
Labels
feature request A feature has been asked for or suggested by the community

Comments

@bednar
Copy link

bednar commented Aug 12, 2024

Checklist

  • I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
  • I have looked into the API documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Describe the problem you'd like to have solved

We are looking to implement device auth flow into our app, but currently there is no way to access the credentialManager from Auth0Provider. This limitation means we would need to reimplement a significant amount of code from Auth0Provider. I believe the original issue (#599) regarding accessing credentialsManager from useAuth0 remains relevant and should be considered for inclusion in v4.

Perhaps also providing access to a preconfigured Auth and networking.Client could assist users in implementing any authorization API from https://auth0.com/docs/api/authentication#authorize-application.

This would enhance flexibility and reduce the need for redundant configurations.

Describe the ideal solution

Being able to utilize the existing Auth0Provider to integrate with new authorization methods would enhance usability and streamline integration processes.

Alternatives and current workarounds

No response

Additional context

@bednar bednar added the feature request A feature has been asked for or suggested by the community label Aug 12, 2024
@tuncaulubilge
Copy link

An alternative (simpler) solution would be to let us pass in an AuthClient to the Auth0Provider.

@poovamraj
Copy link
Contributor

@bednar can you explain the limitation of the methods exposed through credentials manager right now? We would like to understand this deeper.

Ideally we want to move to a fully Hooks based API and understanding your requirements might help us build it.

@bednar
Copy link
Author

bednar commented Jan 23, 2025

We are using react-native-auth0 in our app to authorize users via one-time passwords (sendEmailCode, authorizeWithEmail) and username-password (authorize). If we want to add an additional authorization method using the device flow—such as QR code for TV—we cannot leverage existing features like credentialsManager from react-native-auth0.

@sranka
Copy link

sranka commented Jan 23, 2025

@bednar can you explain the limitation of the methods exposed through credentials manager right now? We would like to understand this deeper.

Ideally we want to move to a fully Hooks based API and understanding your requirements might help us build it.

We need to authorize TVs (android), device authorization flow fits perfectly herein. I have already prototyped the device authorization flow outside of auth0 libraries, it works fine and meets our expectations. The actual issue is an implementation one, react-native-auth0 (4.0.0) does not allow to fill in the result credentials containing a refresh token, so that the TV remains authenticated longer than a day. Knowing the auth0 implementation internals, I ended up with a workaround, we would better avoid such a solution, because of future maintainability of our implementation.

A full prototype implementation of a useDeviceCodeAuthorization hook (that should better fit somehow into useAuth0 hook) is available at https://gist.github.com/sranka/eda08684bfc4755769d9dde4e08836ab. The code that we would like to avoid is storing the credentials and propagating them to useAuth0 hook for the rest of our application to work with them, i.e. these lines: https://gist.github.com/sranka/eda08684bfc4755769d9dde4e08836ab#file-devicecodeauthorization-ts-L222-L237 .

@poovamraj
Copy link
Contributor

@sranka This is awesome :) Any chance you are open to opening a PR with this. We have been meaning to support device flow authorization for sometime now and this implementation looks perfect!

@sranka
Copy link

sranka commented Jan 23, 2025

@sranka This is awesome :) Any chance you are open to opening a PR with this. We have been meaning to support device flow authorization for sometime now and this implementation looks perfect!

I do not plan to open a pull request to the "setCredentials with refreshToken" issue, it is touching the internals in a hacky way. Once it gets resolved ... react-native-auth0uses a different HTTP client (native), a bit different error reporting with own codes, and adding a new functionality into the useAuth0 hook would require some polishing and parameterization ... it is a bigger journey for me to focus on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A feature has been asked for or suggested by the community
Projects
None yet
Development

No branches or pull requests

4 participants