From the course: React: Authentication

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Loading user info from Google

Loading user info from Google - React.js Tutorial

From the course: React: Authentication

Loading user info from Google

- [Instructor] All right, so now that we've added this callback route, we need to implement some functions for this oauthUserInfo thing and creating or updating a user in our database from the user that just logged in, if that's necessary. So here's what that's going to look like. We're going to create a new file here that will contain some utility functions. This is just going to be called something like Google, well, in fact, we can put it inside this googleOauthUtil file if that's easier, just to keep all of this stuff together. And the first function that we're going to create here will be called something like getGoogleUser. Now, what this is going to do is it's going to take a code, we'll just say async (code) like this, and it's going to use that code to load the user's info, right? This is a secret code here that Google gives us to prove that a user has logged into our site and, well, basically agreed that we can use their data. All right, so here's what this is going to look…

Contents