From the course: React: Authentication (2021)
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Handling successful OAuth authentication - React.js Tutorial
From the course: React: Authentication (2021)
Handling successful OAuth authentication
- Okay. So the last step here now is to set up the page that we're redirecting our user back to in this callback route, after we've logged them in and stored their data. So remember that what we're doing is basically redirecting them back to the login page but including a token query parameter that contains the user's info. So what we're going to do now is modify our login page so that it detects if this token query parameter has been provided. And if it has been, then basically it'll just set that in local storage and redirect the user to the user info page. So here's what that's going to look like. Let's open up our login page on our front end and we're going to just add a use effect hook up here that will basically check to see if there's a token in the query parameters and if there is do what we want it to do, right? Set that in local storage and send the user to the user info page. So here's what that's going to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
OAuth basics3m 17s
-
(Locked)
Setting up OAuth on Google6m 33s
-
(Locked)
Adding an OAuth URL route7m 49s
-
(Locked)
Creating a "Sign in with Google" button4m 49s
-
(Locked)
Loading user info from Google5m 32s
-
(Locked)
Creating new users from OAuth data4m 32s
-
(Locked)
Adding an OAuth callback route4m 26s
-
(Locked)
Handling successful OAuth authentication3m 40s
-
(Locked)
-
-
-