Answered

React Native [HTTP 401] - Failed Identity Verification check

  • 3 May 2023
  • 4 replies
  • 932 views

We have recently updated to 4.0.1

Based on the docs, it appears we are using the correct flow of calls when we wither get a new sign-up or a log-in

await Intercom.setUserHash(userHash)

await Intercom.loginUserWithUserAttributes({ email, userId })

await Intercom.updateUser({...})

 

With the above, we get [HTTP 401] - Failed Identity Verification check, after the sign-up call. Interestingly it only occurs for a new user sign up. Login works fine.

 

I have tried adding in await Intercom.loginUnidentifiedUser() before I call loginUserWithUserAttributes but oddly I then get the verification error on the updateUser call.

 

Is this a bug or am I missing something from the docs?
 

 

icon

Best answer by Jacob Cox 7 May 2023, 23:57

View original

4 replies

Userlevel 4
Badge +5

Hi @TomMoran!

The order of events for logging in a User would be:

  1. Before doing anything with Intercom, you’ll want to successfully verify the User that is logging into your app
  2. Set the User Hash
  3. Log the User into Intercom. You’ll need to be logging in an identified user if you’re creating a hash

Things to note for debugging purposes:

  • You said that logging in existing Users works fine, but not new Users. The log-in setup on the Intercom side of things should be the same. Are you doing anything different between the two?
  • If you are assigning a user_id to your user you will need to make sure you are generating the user_hash from that and not the email address.
  • There is a separate Secret Key for iOS and Android. Make sure you’re generating the hash with the key that matches the OS.
  • Make sure you’re logging your Users out of Intercom when they log out of your App
  • Make sure you are generating the correct user_hash by calculating the expected user_hash for a user with our calculator. You can find this in your the security section of your workspace underneath the secret key for your Android, iOS, and Web environments

    Let us know if any of the above get things working for you!

Hi @Jacob Cox,

Tom and I work on the same team, and we are still experiencing some issue’s with version 4.0.1 of the React-Native library on iOS. We are still getting a few 401 when trying to `await Intercom.loginUserWithUserAttributes({ email, userId })`. I double checked the generated user hash with the hash calculator and everything matched up.

Do you think there is a race condition with `Intercom.setUserHash` and `Intercom.loginUserWithUserAttributes` which is causing the hash to be not set in time? Below is a snippet of how we call the functions
 

await Intercom.setUserHash(intercomHash.data.getIntercomHash)
await Intercom.loginUserWithUserAttributes({ email, userId })


Cheers,
Walter

Userlevel 4
Badge +5

Hi @Tech Team !

I couldn’t say for sure if this is a situation with a race condition. I think the best option here is for you to reach out to support with all of the details around what you’re running into along with some sample Users who have experienced this crash. They’ll be able to look at logs and be able to open an issue with our Product Team if they can’t get to the bottom of things.

One thing you might want to check out as well, is that we have a more recent version of that React Native SDK (vers 5.1.1), here. You might want to test with that one to see if you’re still running into the same issue. 

Hello @Tech Team 
Did you manage to fix your problem by any chance ? We are facing the same issue.

Thanks

Reply