React-Native iOS - Error in loginUserWithUserAttributes | Community
Skip to main content

Hi Intercom team, we receive several errors after trying to login a user with attributes using react-native sdk.

We check if the user is logged in before making a Intercom.loginUserWithUserAttributes call.


A short stack-trace for the error we receive:

 

code: 102,
domain: io.intercom.ios.error.network,
message: Error in loginUserWithUserAttributes,
name: Error,
NSLocalizedDescription: HTTP Error: 400 bad request


We send email and userId to the method call, like this: 
Intercom.loginUserWithUserAttributes({ email, userId })

 

Could you help us understand why we still get an error, I’ve run a console.log for both email and userId and both seem legit.

Hey ​@Dev Planable, Emily here from Support Engineering at Intercom 👋🏼

 

A 400 Bad Request error with code 102 when calling Intercom.loginUserWithUserAttributes in the React Native SDK can be caused by several factors:

  • If you send both email and userId, you must calculate the HMAC (user hash) for identity verification using the userId value, not the email. If the HMAC is calculated incorrectly, authentication will fail.
  • Both email and userId must be valid, non-empty strings. Double-check that neither is undefined or null.
  • Ensure all attribute values match the expected types and formats. For example, if a field is defined as a number or date, sending a string or incorrectly formatted value can cause a 400 error.

To resolve:

  • Confirm both userId and email are valid, non-empty strings.
  • If using identity verification, ensure the HMAC is generated from userId if both are present.
  • Check that all attribute values match the expected types and formats.

Hope this helps! 💪🏼


Reply