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.
Best answer by Emilygav
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.
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.
Hey @Emilygav -- this is happening to us a ton as well and is polluting our Bugsnag. In our case however, we are just passing userId: `await Intercom.loginUserWithUserAttributes({ userId });`
And then we get an error that looks like this
code 102
domain io.intercom.ios.error.network
userInfo { "NSLocalizedDescription": "HTTP Error: 400 bad request" }
As I mentioned, it’s happening a ton and is quite frustrating, so any help on the matter would be very much appreciated!
A 400 Bad Request in loginUserWithUserAttributes usually means Intercom expects either userIdoremail but not both in some configurations. Make sure your Intercom app is set to identify users by the field(s) you’re sending. Also, check for:
email format correctness (no extra spaces)
userId uniqueness and length (<255 chars)
SDK initialization completed before login call
Try calling Intercom.registerIdentifiedUser({ userId }) or just { email } depending on your setup to see if that resolves the 400 error.
Hey @Somesh Selvachandran @Sam Moore @Gianni Settino sorry for the long wait on this one. Are you all still experiencing this issue?
The likely cause for this is a known React Native SDK race where logout()/setUserJwt() resolve before native completes, so loginUserWithUserAttributes({ userId }) fires too soon and returns 400 (code 102). It’s intermittent and spams error trackers; often no 4xx hits our backend.
Fixes:
Upgrade to the latest @intercom/intercom-react-native (and iOS SDK); this issue was addressed.
Don’t re-login on every app foreground. Only login once per session; use Intercom.isUserLoggedIn() to skip redundant calls.
Ensure userId is a non-empty string (String(userId)), not a number/UUID object.
If Identity Verification is enforced for mobile, you must call setUserJwt(jwt) before login; otherwise you’ll see auth errors.
If it still reproduces after upgrading and serializing, share the exact sequence (logout/setUserJwt/login), SDK versions, and whether IDV/JWT is enabled so we can spot the timing edge.