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

[Question] Integration with React Native #24

Closed
yeguacelestial opened this issue Sep 30, 2021 · 4 comments
Closed

[Question] Integration with React Native #24

yeguacelestial opened this issue Sep 30, 2021 · 4 comments

Comments

@yeguacelestial
Copy link

yeguacelestial commented Sep 30, 2021

Hello, I followed the docs. Everything is well written, and this is probably the best auth library I've seen for FastAPI.

However, I got lost in the woods of FARM stack. How can this library be integrated with a React Native front-end? What flow should one follow? Been lurking around but it seems like a quite uncommon use case.

@JonasKs
Copy link
Member

JonasKs commented Sep 30, 2021

Hi! Thank you for the kind words. 😊

Any flow fetching a token would work. Preferably client side applications should use the Authorization Code (using PKCE) flow. That’s the flow the OpenAPI docs also use.

I’m not a frontend developer so I’ll tag @h3rmanj, he might be able to correct me if the following is wrong:

You can use the Microsoft MSAL react package to handle all token fetching in react. You should set up your app registration in Azure AD just as you did for your OpenAPI docs(with a different redirect URI). This tutorial seem to use the correct flow and libraries.

Quote from the msal-react GitHub README:

This version of the library uses the OAuth 2.0 Authorization Code Flow with PKCE.

@h3rmanj
Copy link
Member

h3rmanj commented Sep 30, 2021

I don't really have any experience with React Native, and I don't really know if Microsoft's msal packages are Native friendly. I'm assuming they are not as they probably relies heavily on browser APIs and the DOM, but I might be wrong. If it doesn't work, react-native-msal might be an alternative? As Jonas said you should still use the Authorization Code Flow with PKCE.

@JonasKs
Copy link
Member

JonasKs commented Oct 1, 2021

Seems like there's some specific examples on the PKCE flow on the official website, using this library. An example can be found here (remember to look at the V2 docs).

Good luck! 🚀

@JonasKs
Copy link
Member

JonasKs commented Oct 2, 2021

@yeguacelestial I believe we’ve answered your question as best as we can, so I’m going to close this issue.

Feel free to re-open if you have any more questions.

@JonasKs JonasKs closed this as completed Oct 2, 2021
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

3 participants