google-auth-struct
v1.0.7
Published
Package to facilitate sign in and handle of data with google account
Downloads
9
Maintainers
Readme
Google-auth-struct
Installation and Usage
You can install google-auth-struct in your project's node_modules
folder.
To install the latest version on npm locally and save it in your package's
package.json
file:
npm install google-auth-struct
To use it, just import it in your code:
const { googleAuth } = require("google-auth-struct")
Methods and functions
The googleAuth(token, clientId) function allows you to use Google's authentication service. It takes the token (credential) and the Client ID (available in the 'credentials' tab of the Google Developer Console) as parameters.
Use the req.body in your authentication route to get the credential:
const token = req.body.credential
By using the googleAuth() function, it is possible to use methods to help handling user data.
The .getUserData() method returns the user's general information as an object:
await googleAuth(token, clientId).getUserData()
The .getUserName() method returns the user's name as a string:
await googleAuth(token, clientId).getUserName()
The .getUserEmail() method returns the user's email address as a string:
await googleAuth(token, clientId).getUserEmail()
The .getUserPfp() method returns the user's profile picture as a string (URL):
await googleAuth(token, clientId).getUserPfp()
Note
The google-auth-struct NPM has a promise-based structure.
License
Google-auth-struct copyright© 2022-present Bruno Duarte [email protected]
Google-auth-struct is a free software licensed under the MIT license (LICENSE) file for more details.