# Check Session Not Working With Social Provider

**URL:** <https://community.auth0.com/t/check-session-not-working-with-social-provider/89385>\
**Category:** Get Help\
**Tags:** auth, social-connections, social-provider, auth0\
**Created:** [August 24, 2022, 3:53pm UTC](https://community.auth0.com/t/check-session-not-working-with-social-provider/89385 "2022-08-24T15:53:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hammad.rasheed](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/hammad.rasheed/32/39513_2.png) [@hammad.rasheed](https://community.auth0.com/u/hammad.rasheed)\
**Post date:** [August 24, 2022, 3:53pm UTC](https://community.auth0.com/t/check-session-not-working-with-social-provider/89385/1 "2022-08-24T15:53:20Z")

</div>

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:

```auto
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:

```auto
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:

```auto
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

---

<div class="post-metadata">

**Author:** ![thameera](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/thameera/32/13430_2.png) [@thameera](https://community.auth0.com/u/thameera)\
**Post date:** [August 25, 2022, 6:23am UTC](https://community.auth0.com/t/check-session-not-working-with-social-provider/89385/2 "2022-08-25T06:23:28Z")

</div>

The type of connection (social or otherwise) should not have any bearing on checkSession.

One possible issue is that you are specifying an `audience` in the checkSession call, but not in the original authorize call. To confirm if this is related, can you try adding the same audience to the authorize call as well and see if it works?

If that does not work, can you take a look at the Logs section in your tenant to see if it has any descriptive error log? Based on that, we can take a further look.

---

<div class="post-metadata">

**Author:** ![hammad.rasheed](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/hammad.rasheed/32/39513_2.png) [@hammad.rasheed](https://community.auth0.com/u/hammad.rasheed)\
**Post date:** [August 25, 2022, 7:19am UTC](https://community.auth0.com/t/check-session-not-working-with-social-provider/89385/3 "2022-08-25T07:19:52Z")

</div>

Thanks a lot for your response. I really appreciate that.

Sure, let me verify it by adding the audience in the authorized call and I’ll keep an eye on the logs as well.

---

<div class="post-metadata">

**Author:** ![hammad.rasheed](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/hammad.rasheed/32/39513_2.png) [@hammad.rasheed](https://community.auth0.com/u/hammad.rasheed)\
**Post date:** [August 26, 2022, 2:11pm UTC](https://community.auth0.com/t/check-session-not-working-with-social-provider/89385/4 "2022-08-26T14:11:34Z")

</div>

Hi @thameera,

Thanks a lot for your help. Setting up the `audience` properly did the magic. It’s now working as expected. Here’s how I have modified it to work:

Auth0 instance:

```auto
const auth0Instance = new auth0.WebAuth({
  domain: process.env.NEXT_PUBLIC_AUTH0_DOMAIN || '',
  clientID: process.env.NEXT_PUBLIC_AUTH0_CLIENTID || '',
  audience: process.env.NEXT_PUBLIC_AUTH0_AUDIENCE || '',
  scope: 'openid profile email',
  responseType: 'token id_token'
})

```

Auth0 session verification:

```auto
auth0Instance.checkSession(
    {
        audience: process.env.NEXT_PUBLIC_AUTH0_AUDIENCE || '',
        scope: 'openid profile email',
        redirectUri: window.location.origin + '/login'
    },
   function(err, response) {}
)

```

Really appreciate the help.

Thanks,  
Hammad Rasheed

---

<div class="post-metadata">

**Author:** ![thameera](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/thameera/32/13430_2.png) [@thameera](https://community.auth0.com/u/thameera)\
**Post date:** [August 28, 2022, 11:55pm UTC](https://community.auth0.com/t/check-session-not-working-with-social-provider/89385/5 "2022-08-28T23:55:11Z")

</div>

Great, thanks for sharing the working solution as well.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [November 4, 2022, 2:28pm UTC](https://community.auth0.com/t/check-session-not-working-with-social-provider/89385/6 "2022-11-04T14:28:33Z")

</div>


