Hi,
I hope you are doing well.
I am stuck with a problem and confused about how to solve it. Please see the problem statement:
I have implemented the Google social login using the auth0Instance.authorize
method from the SDK. The sign-in works as expected and I am able to redirect my user back to my application but the problem occurs when I try to check the session using auth0Instance.checkSession
method from the SD but It’s always returning me the login_error
.
Please see the following piece of code I am using:
Auth0 instance configuration:
import auth0, { AuthOptions } from 'auth0-js'
const auth0Instance = new auth0.WebAuth({
domain: process.env.NEXT_PUBLIC_AUTH0_DOMAIN || '',
clientID: process.env.NEXT_PUBLIC_AUTH0_CLIENTID || '',
scope: 'openid profile email ' + process.env.NEXT_PUBLIC_AUTH0_AUDIENCE || '',
responseType: 'token id_token'
})
This is working as expected when I start the authentication process:
auth0Instance.authorize({
connection: 'google-oauth2',
scope: 'openid profile email',
redirectUri: 'http://localhost:4200/social-auth'
})
And when I try to check the session back using:
auth0Instance.checkSession(
{
audience: process.env.NEXT_PUBLIC_AUTH0_AUDIENCE,
redirectUri: window.location.origin + '/login'
},
function(err, response) {}
)
This is returning login_error
Please take a note here, I have already added the ClientID & ClientSecret from the Google App in the social connections.
Please let me know if you need any other information as well.
Looking forward to hearing from you.
Thanks & Best Regards,
Hammad Rasheed