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

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…

Contents