Clever Social Connection

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!!

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!

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’, {
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
});
});
}

1 Like

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

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

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!

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

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

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

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);
    });
}

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

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.