From the course: React: Authentication
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Handling successful OAuth authentication - React.js Tutorial
From the course: React: Authentication
Handling successful OAuth authentication
- [Shaun] Okay, so the last step in this whole process, as I said, is to modify our login page because after our user finishes going through this callback here, right? After this finishes, it's going to redirect our user to the login page, but it's going to set this token query parameter. And so essentially what we want our login page to do is check to see whether that's there. And if it is, then to log the user in. So here's what this is going to look like. We're going to go to the login page. And the first thing we're going to do is get the value of that token query parameter if it's there. And here's what this is going to look like. We're going to say, underneath all of this stuff here, we'll start off by saying const. And we're going to use the use location hook, so we'll say const location equals useLocation like so. And now what we're going to do here is we're going to say const queryParams equals new URLSearchParams. And we're going to pass location.search to that. And the last…
Contents
-
-
-
-
-
-
(Locked)
OAuth basics3m 45s
-
(Locked)
Setting up OAuth on Google7m 39s
-
(Locked)
Adding an OAuth URL route6m 16s
-
(Locked)
Creating a "sign-in with Google" button6m
-
(Locked)
Adding an OAuth callback route4m 17s
-
(Locked)
Loading user info from Google3m 30s
-
(Locked)
Creating new users from OAuth data5m 49s
-
(Locked)
Handling successful OAuth authentication4m 7s
-
(Locked)
-
-
-
-