strapi-examples
strapi-examples copied to clipboard
Google auth not working
** Node.js : 14.1.7.1 ** ** strapi : 4.0.0 **
When after choosing an account from google in google signup it redirects to the frontend URL. from the frontend when I call the api/connect/google/redirect?access_token=XXX
then it shows me the 401 error unauthorized error. I attached the URL which I call from the frontend. I attached a screenshot.
After selecting a Gmail account, it's not created the user in dB. that's the reason it returns a 401
Some updates which might help in troubleshooting this issue. This app is broken with Strapi V4 backend.
The issue occurs when front end call back Strapi with auth code on the url locahost:1337/api/auth/google/callback?access_token={token}. Strapi V4 is not able to parse the jwt token and fails with {"name":"JsonWebTokenError","message":"invalid algorithm"}
Not sure why JsonWebToken fails as Strapi generated the token using JsonWebToken itself.
Regards M
Also facing the same issue.
in header, if you put
{
headers: {
Authorization: `token ${token}`
}
token is any random string for temporary you use this for a google auth so temp it working
Authorization
in header, if you put
{ headers: { Authorization: `token ${token}` }
token is any random string for temporary you use this for a google auth so temp it working
Thanks mate. Adding any random string there worked as you said.
this is temp. so once strapi fix you will need to remove this headers
http://localhost:1337/api/auth/google/callback
add 'api' in the url