AuthenticationException: The configured environment(production) and the access token one(null) don't match.

I am using Unity Services and need to authenticate with SignInWithCustomID. I followed the documentation:

  1. Call the Token Exchange API to retrieve a stateless token.
  2. Call the Sign In With Custom ID API.

I successfully retrieved the accessToken and sessionToken, but when I call:

csharp

Copy code

AuthenticationService.Instance.ProcessAuthenticationTokens(userTokens.AccessToken, userTokens.SessionToken);

I get the following error:

java

Copy code

AuthenticationException: The configured environment(production) and the access token one(null) don't match.

My understanding is that during the “Call the Token Exchange API to retrieve a stateless token.” step, I need to pass the environmentId, and I have done so (I also tried passing an incorrect ID and was unable to retrieve the corresponding accessToken).

Additionally, I am unable to successfully call both APIs every time in Unity (while testing locally, I haven’t exceeded the frequency limit). When I use UnityWebRequest.Post, it often takes a long time and results in a timeout.