google-sociallogin-package
v1.0.1
Published
A Node.js package for integrating Google social login using OAuth and Google APIs.
Maintainers
Readme
google-sociallogin-package This code provides two functions to handle Google login using OAuth2:
googleLogin(clientId, clientSecret, redirectUri): Generates a Google login URL that users can visit to authenticate and authorize access.
getUserInfo(code, clientId, clientSecret, redirectUri): After the user logs in, this function retrieves the user's basic information (such as name and email) using the authorization code provided by Google.
The code is exported as a default object, so both functions can be accessed together when imported into another project.
INSTALL
npm install google-sociallogin-package
Usage:
import googleAuth from 'google-sociallogin-package';
// Using the googleLogin function
const loginUrl = googleAuth.googleLogin('YOUR_GOOGLE_CLIENT_ID', 'YOUR_GOOGLE_CLIENT_SECRET', 'YOUR_REDIRECT_URI');
console.log('Login URL:', loginUrl);
// After user logs in, use the authorization code to get user info
const userInfo = await googleAuth.getUserInfo('AUTHORIZATION_CODE', 'YOUR_GOOGLE_CLIENT_ID', 'YOUR_GOOGLE_CLIENT_SECRET', 'YOUR_REDIRECT_URI');
console.log('User Info:', userInfo);
