I am trying to setup intercom in react native ,getting issue of Failed Identity Verification check

440 Views Asked by At

I am trying to set intercom in react native ,my hash is generating properly compared with HASH generator,passing exact params ,verified every key and setup,still getting issue of

Error logging in user: [Error: ERROR - [HTTP 401] - Failed Identity Verification check]

        const email = hookData.userSettingData?.intercom?.email_address;
        const user_id =
          hookData.userSettingData?.intercom?.Tradesocio_id.toString();
        const name = hookData.userSettingData?.intercom?.Name;
        const tradesocioUrl =
          hookData.userSettingData?.intercom?.Tradesocio_url;
        const secretKey = "my secretKey";
        const userHash = await calculateHMAC(user_id, secretKey);
        Intercom.setUserHash(userHash)
          .then(() => {
            // User hash set successfully
            console.log("User hash set successfully");
          })
          .catch((error) => {
            // Error occurred while setting user hash
            console.error("Error setting user hash:", error);
          });
        const userId =
          hookData.userSettingData?.intercom?.Tradesocio_id.toString();
        Intercom.loginUserWithUserAttributes({
          email,
          userId,
        })
          .then(() => {
            // Handle the resolved Promise
            console.log("User logged in successfully");
            // Perform any additional actions
          })
          .catch((error) => {
            // Handle the rejected Promise
            console.error("Error logging in user:", error);
            // Perform error handling
          });

        Intercom.updateUser({
          // User attributes
          email: email,
          userId: userId,
          name: name,
          phone: "",
          languageOverride: "languageOverride",
          signedUpAt: 1621844451,
          unsubscribedFromEmails: true,
          customAttributes: {
            userCustomAttribute: 123,
            hasUserCustomAttribute: true,
          },
        })
          .then(() => {
            // Handle the resolved Promise
            console.log("User updated successfully");
            // Perform any additional actions
          })
          .catch((error) => {
            // Handle the rejected Promise
            console.error("Error updating user:", error);
            // Perform error handling
          });
        
        Intercom.displayMessenger();

I am getting this as result

User hash set successfully

Error logging in user: [Error: ERROR - [HTTP 401] - Failed Identity Verification check]

1

There are 1 best solutions below