strapi-google-auth-with-token
v5.0.1
Published
Google auth with token helps you to easily create google authentication available for your users with idToken. It uses the official google-auth-library library to execute the actions. You can get it working in seconds in your application. EASY!
Readme
🛡️ Google One Tap Auth in Strapi
Google auth with token helps you to easily create Google authentication for your users using the Sign In With Google button. It uses the official google-auth-library to execute the actions and verify the token. You can get it working in seconds 🫰.
Google makes One Tap authentication for smooth authentication with just one click, no need for redirection URL

Features
- Official Google APIs integration
- One Tap support using idToken One Tap
- Uses Strapi default user-permission collection
- JWT Authentication
- Sanitized response
- Highly secure
- Saves user first and last name in Strapi user entity
- Saves user Gmail profile picture in Strapi user entity
⚙️ Installation in Strapi app
- Install the plugin using npm or yarn
npm install strapi-google-auth-with-token
# or
yarn add strapi-google-auth-with-token- Add the following lines of code in the file: config/plugins.js or config/plugins.ts
module.exports = {
'strapi-google-auth-with-token': {
enabled: true,
fullNameField: 'fullName', // (Optional) This is the attribute name in Strapi user entity where you will save the user full name
firstNameField: 'firstName', // (Optional) This is the attribute name in Strapi user entity where you will save the user first name
lastNameField: 'lastName', // (Optional) This is the attribute name in Strapi user entity where you will save the user last name
pictureField: 'profileImage', // (Optional) This is the attribute name in Strapi user entity where you will save the user Gmail picture
pictureFolderName: 'profiles', // (Optional) The name of the folder where user Gmail picture will be stored
// PS: You can use only some of them or none of them
// BTW: You need to create these attributes in the Strapi user entity if you provide them in this config
},
};
// or in typescript for config/plugins.ts
export default () => ({
"strapi-google-auth-with-token": {
enabled: true,
fullNameField: 'fullName', // (Optional) This is the attribute name in Strapi user entity where you will save the user full name
firstNameField: 'firstName', // (Optional) This is the attribute name in Strapi user entity where you will save the user first name
lastNameField: 'lastName', // (Optional) This is the attribute name in Strapi user entity where you will save the user last name
pictureField: 'profileImage', // (Optional) This is the attribute name in Strapi user entity where you will save the user Gmail picture
pictureFolderName: 'profiles', // (Optional) The name of the folder where user Gmail picture will be stored
// PS: You can use only some of them or none of them
// BTW: You need to create these attributes in the Strapi user entity if you provide them in this config
},
});
🔑 Configuration (Get Google Client Id)
- Create a Google project from the Google Cloud Console.
- Create OAuth Consent Screen (Nav Menu -> APIs & Services -> OAuth consent screen).
- Go to Credentials, click create credentials -> OAuth Client ID
- Put the CLIENT_ID in the Strapi Content Management page > Google Credential, and save it.

❓ How to use
Get User JWT token and user data
{
method: 'POST',
path: 'STRAPI_BACKEND_URL/strapi-google-auth-with-token/auth', // like: http://localhost:1337/strapi-google-auth-with-token/auth
data: {
token: idToken // get the token from the Google sign-in button
}
}🐞 Report Bugs/Issues
Any bugs/issues you may face can be submitted as issues in the GitHub repo.
