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

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