# Clever Social Connection

**URL:** <https://community.auth0.com/t/clever-social-connection/53795>\
**Category:** Integration Help\
**Tags:** custom-social-connec\
**Created:** [November 24, 2020, 4:00pm UTC](https://community.auth0.com/t/clever-social-connection/53795 "2020-11-24T16:00:56Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![itekk.eml0e](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/itekk.eml0e/32/25815_2.png) [@itekk.eml0e](https://community.auth0.com/u/itekk.eml0e)\
**Post date:** [November 24, 2020, 4:00pm UTC](https://community.auth0.com/t/clever-social-connection/53795/1 "2020-11-24T16:00:56Z")

</div>

My client is using auth0 to login to the application. Now I would like to integrate **Clever SSO** with auth0 to login to my application.  
I tried creating a new social connection and gave the client id and secret from clever. But it’s not working. I get the below message when I click on Try Connection.  
“error”: “invalid\_request”,  
“error\_description”: “Invalid user id.”

What am I doing wrong?  
Can you please help me out quickly?

Thanks in advance!!

---

<div class="post-metadata">

**Author:** ![James.Morrison](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/james.morrison/32/13507_2.png) [@James.Morrison](https://community.auth0.com/u/James.Morrison)\
**Post date:** [November 25, 2020, 3:57pm UTC](https://community.auth0.com/t/clever-social-connection/53795/2 "2020-11-25T15:57:22Z")

</div>

Hey there @itekk.eml0e, welcome to the Auth0 Community!

I would be happy to help. When you get a chance can you send me a direct message with your tenant name so I can double how everything is set up in your dashboard, please? Thanks in an advance!

---

<div class="post-metadata">

**Author:** ![itekk.eml0e](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/itekk.eml0e/32/25815_2.png) [@itekk.eml0e](https://community.auth0.com/u/itekk.eml0e)\
**Post date:** [November 25, 2020, 4:17pm UTC](https://community.auth0.com/t/clever-social-connection/53795/4 "2020-11-25T16:17:57Z")

</div>

I had to add below code in Fetch User Profile Script and it worked!

function(accessToken, ctx, cb) {  
request.get(’ [https://api.clever.com/v2.1/me](https://api.clever.com/v2.1/me)’, {  
headers: {  
‘Authorization’: 'Bearer ’ + accessToken  
}  
}, function(e, r, b) {  
if (e) return cb(e);  
if (r.statusCode !== 200)  
return cb(new Error('StatusCode: ’ + r.statusCode));  
var profile = JSON.parse(b);  
cb(null, {  
user\_id: profile.data.id  
});  
});  
}

---

<div class="post-metadata">

**Author:** ![James.Morrison](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/james.morrison/32/13507_2.png) [@James.Morrison](https://community.auth0.com/u/James.Morrison)\
**Post date:** [November 25, 2020, 4:23pm UTC](https://community.auth0.com/t/clever-social-connection/53795/5 "2020-11-25T16:23:00Z")

</div>

Awesome, I’m glad it all came together @itekk.eml0e!

---

<div class="post-metadata">

**Author:** ![itekk.eml0e](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/itekk.eml0e/32/25815_2.png) [@itekk.eml0e](https://community.auth0.com/u/itekk.eml0e)\
**Post date:** [December 2, 2020, 6:47am UTC](https://community.auth0.com/t/clever-social-connection/53795/6 "2020-12-02T06:47:49Z")

</div>

Hi @James.Morrison,

When I click on Try connection it works fine. But when I try to login from Clever, it shows below message.  
What am I doing wrong?

Error message:  
**invalid\_request** : You may have pressed the back button, refreshed during login, opened too many login dialogs, or there is some issue with cookies, since we couldn’t find your session. Try logging in again from the application and if the problem persists please contact the administrator.

TRACKING ID: 4995b819f5d8fa459eb9

---

<div class="post-metadata">

**Author:** ![James.Morrison](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/james.morrison/32/13507_2.png) [@James.Morrison](https://community.auth0.com/u/James.Morrison)\
**Post date:** [December 4, 2020, 2:35pm UTC](https://community.auth0.com/t/clever-social-connection/53795/7 "2020-12-04T14:35:54Z")

</div>

I’m sorry to hear that @itekk.eml0e, can you direct message me a HAR file capture with me of the current error occurring so I can work with our support team to take a look at the flow breakdown? Thanks!

> **[Generate and Analyze HAR Files](https://auth0.com/docs/troubleshoot/troubleshooting-tools/generate-and-analyze-har-files)**
>
> Learn how to troubleshoot with HAR files and steps to generate a HAR file.

---

<div class="post-metadata">

**Author:** ![itekk.eml0e](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/itekk.eml0e/32/25815_2.png) [@itekk.eml0e](https://community.auth0.com/u/itekk.eml0e)\
**Post date:** [December 4, 2020, 2:54pm UTC](https://community.auth0.com/t/clever-social-connection/53795/8 "2020-12-04T14:54:16Z")

</div>

I have sent.  
[https://community.auth0.com/t/clever-social-connection/54217/3](https://community.auth0.com/t/clever-social-connection/54217/3)

---

<div class="post-metadata">

**Author:** ![maksim.suhlob](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/maksim.suhlob/32/27216_2.png) [@maksim.suhlob](https://community.auth0.com/u/maksim.suhlob)\
**Post date:** [January 28, 2021, 6:25pm UTC](https://community.auth0.com/t/clever-social-connection/53795/9 "2021-01-28T18:25:14Z")

</div>

hi @itekk.eml0e  
can you share a step-by-step instruction on how to connect Clever to Auth0?

---

<div class="post-metadata">

**Author:** ![ivy](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ivy/32/15179_2.png) [@ivy](https://community.auth0.com/u/ivy)\
**Post date:** [September 21, 2023, 8:43am UTC](https://community.auth0.com/t/clever-social-connection/53795/11 "2023-09-21T08:43:56Z")

</div>

Here’s a sample script for fetching the user profile:

```auto
function fetchUserProfile(accessToken, ctx, callback) {
  // NOTE: `fetchFromClever` has to be inlined as Auth0 only seems to allow a
  // single top-level function:
  function fetchFromClever({ url, accessToken }) {
    const fetch = require("node-fetch");

    return fetch(url, {
      method: "GET",
      headers: {
        Authorization: `Bearer ${accessToken}`,
        Accept: "application/json",
      },
    }).then((response) => {
      if (response.status !== 200) {
        return Promise.reject(
          new Error(
            `Clever API: Non-200 status code. statusCode=${response.status}`
          )
        );
      }
      return response.json();
    });
  }

  fetchFromClever({ url: "https://api.clever.com/v3.0/me", accessToken })
    .then((userInfo) => {
      if (userInfo.type !== "user") {
        return Promise.reject(
          new Error(
            `Clever API: Invalid response type. Expected 'user', got type=${userInfo.type}`
          )
        );
      }
      return fetchFromClever({
        url: `https://api.clever.com/v3.0/users/${userInfo.data.id}`,
        accessToken,
      });
    })
    .then((userDetail) => {
      const {
        id,
        email,
        name: { first: first_name, last: last_name },
      } = userDetail.data;
      const profile = { user_id: id, email, first_name, last_name };
      callback(null, profile);
    })
    .catch((error) => {
      callback(error);
    });
}

```

---

<div class="post-metadata">

**Author:** ![cristiang\_aoeu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/cristiang_aoeu/32/54788_2.png) [@cristiang\_aoeu](https://community.auth0.com/u/cristiang_aoeu)\
**Post date:** [February 14, 2024, 6:35pm UTC](https://community.auth0.com/t/clever-social-connection/53795/12 "2024-02-14T18:35:58Z")

</div>

Was there a resolution to this issue? @itekk.eml0e @James.Morrison

---

<div class="post-metadata">

**Author:** ![cristiang\_aoeu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/cristiang_aoeu/32/54788_2.png) [@cristiang\_aoeu](https://community.auth0.com/u/cristiang_aoeu)\
**Post date:** [February 14, 2024, 6:50pm UTC](https://community.auth0.com/t/clever-social-connection/53795/13 "2024-02-14T18:50:46Z")

</div>

The Clever Portal SSO link initiates an authorization through Clever. Since we need to initiate the Auth0 authorization flow the Clever app callback (must be the first one in the URI list) should point to a web route (e.g. your application) that initiates a redirect to the Auth0 Clever SSO authorization flow (e.g. /authorize?connection=Clever-Connection-Name). This has been verified by Clever support.
