From the course: React: Authentication (2021)
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Adding an OAuth callback route - React.js Tutorial
From the course: React: Authentication (2021)
Adding an OAuth callback route
- Okay, so now that we've completed these two helper functions, let's actually implement our Google OAuth callback route. This one's actually going to be pretty simple. Now that we've delegated most of the logic to different helper functions. So, we'll start off by importing a few things. We're going to import are jsonwebtoken package. So import jwt from jsonwebtoken. And then we're going to import our two helper functions. Import getGoogleUser from util getGoogleUser. And import updateOrCreateUserFromOauth, from util updateOrCreateUserFromOauth. And then let's define the route. So the route here is going to be called googleOAuthCallbackRoute. Again, because this is the route that Google is going to send users back to once they've given permission. So the path here is going to be slash auth slash Google slash callback. The method is going to be a get method and the handler here which is going to be async is going…
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)
-
-
-