GoogleAuth helps you to easily create google authentication available for your users. It uses the official google-auth library to execute the actions.
npm install @spotodo0/strapi-google-authjs
'google-auth': {
enabled: true,
},
`
Configuration
1. Create a google project from the Google Cloud Console.
2. Create OAuth Consent Screen (Nav Menu -> APIs & Services -> OAuth consent screen).
3. Go to Credentials, click create credentials -> OAuth Client ID
4. Input the CLIENT_ID, CLIENT_SECRET, REDIRECT URL & the Scopes in the plugin page of Strapi, and save it.
How to use
$3
`js
{
method: 'GET',
path: 'STRAPI_BACKEND_URL/strapi-google-auth/init',
}
`
After google login, it will redirect the user back to the redirect URL mentioned in the Google project console, with a code parameter in the URL. https://REDIRECT_URL?code=REDIRECTION_AUTH_CODE
$3
Use the REDIRECTION_AUTH_CODE you have recieved from the step 1 to make the second request to authenticate the user.
`js
{
method: 'POST',
path: 'STRAPI_BACKEND_URL/strapi-google-auth/user-profile',
data: {
code:REDIRECTION_AUTH_CODE
}
}
`
$3
Use the JWT token to fetch the user details.
`js
{
method: 'GET',
path: 'STRAPI_BACKEND_URL/strapi-google-auth/me',
header: {
authorization:Bearer
}
}
`
$3
Use the JWT token to fetch the user details.
`js
{
method: 'POST',
path: 'STRAPI_BACKEND_URL/strapi-google-auth/update-password',
header: {
authorization:Bearer
},
data:{
"password":""
}
}
``