Hello! Welcome to the Auth0 Community. Yes, there is! I am working on a sample that may show how to do that. I may not be able to share the full-sample too soon but I can definitely share the code snippets within the next weeks.
Despite adding a User (and A) confirming the user exists in the backend, and B) making the user validate their email address)… the sample app always returns a 401 (Error - Unauthorized)
I want to figure this out, but I don’t see any useful logs anywhere. Are there any know issues w/ the Getting Started guide?
Hello! Welcome to the Auth0 Community. You can view helpful logs to debug and troubleshoot your Auth0 integration in your Tenant. Go to the Auth0 Dashboard and click on the “Monitoring” tab on the left side bar. Then click on “Logs”.
Thanks Dan - the issue is a “Failed Exchange” after a “Success Login”
This is happening for Chrome & Firefox (desktop).
I saw a similar issue reported for an Angular SPA app back in 2020 (Success Login and a Failed Exchange - #9 by sagun786), but I do not know where those configuration settings are stored. (I did a text search for “grant_types” and “token_endpoint_auth_method” in the React sample app, but nothing came up.
Hi @craigp, thanks for sharing that information. As mentioned in the issue that you just shared sounds like that error is related to the Authorization flow used when logging in. To confirm that and help you troubleshoot this issue, could you please help us with the following:
Share with us the type code of the “Failed Exchange” error you got. You can see the type code of it by clicking on the “Failed Exchange” event. A more detailed page of the error will show up. Under the “Details” section, you’ll see a JSON object with more details of the error. The “type” key is the type code.
Validate that the Auth0 Application type you’re using is a “Single Page Application”.
In case the Auth0 application you’re using is not a “Single Page Application”, do the following to change it:
Go to the "Settings " tab of your Auth0 application.
Under the "Application Propiertes " in your Auth0 application, select “Single Page Application” as the "Application type ". A confirm dialog may appear, click on "Confirm " and then click on the "Save Changes " button at the bottom of the page.
Before trying to log in again, I suggest clearing the cookies first. You can do that by navigating to the application, clicking on the information icon at the right of the address bar, and clicking on Cookies. Then remove all the cookies for this site and try to log in.
Please let us know if that works for you or if you still need help.
Hi, is there any guidance on how to perform auth checks and access the bearer token in React Router’s newloaders and actions? The challenge is these sit above/outside of the Auth0Provider component.
Hi, having a problem with my Authentication Guards. When you’re not logged in the isAuthenticated && code works, but the guarded pages load when you’re not logged in. I modified the Authentication Guard component too, but can’t remember why. Abridged version of App component:
To confirm that I understand your issue correctly, you’re not redirected to log in with Auth0 when you visit a page that requires an authenticated user (e.g., the /edit_profile route in your example). Is that correct?
From the code snippets you shared, I noticed you modified the AuthenticationGuard component to pass props down the wrapped component, which is correct. However, please notice that you’re not returning the HOC component that wraps your component with the withAuthenticationRequired HOC in the AuthenticationGuard component.
Could you try to modify your AuthenticationGuard component as follows:
This will ensure that when an anonymous user visits your component, they are redirected to the login page and returned to the page they were redirected to after login.
Hey @byron.motoche , Is there a updated version of this SDK which uses React Router V6.4 ,which uses createbrowserrouter instead of Browser router and usenavigation for example ?
From what I see, at the “Call a Protected API From React” part, you are showing the “Implicit Flow” way of connecting the backend to our SPA. This flow is actually insecure right? Could we also add a tutorial to show the secure way with authorization code flow with the PKCE extension? Sorry if I’m mistaken, I am new to auth stuff.
Hi, @rampandey , welcome to the Auth0 Community and thanks for reading our guide!
Currently, we don’t have a code sample that uses the createBrowserRouter router. We’ll work on a sample that shows how to do that. We may not be able to share the full sample too soon, but we can definitely share the code snippets within the next few weeks.
The Auth0 React SDK under the hood uses the Authorization Code Grant Flow with PKCE. To prevent confusion, we’ll be more explicit about which Flow is used in the guide. Thanks for sharing this concern, your feedback helps us improve our developer content.
The Implicit Flow is no longer considered a best practice for requesting access tokens. However, it offers a streamlined workflow if the application only needs an ID token to perform user authentication.
Thank you once more for taking the time to use our content and share your feedback.