google-signingooglesigninaccountfedcm

[GSI_LOGGER]: FedCM get() rejects with IdentityCredentialError: Error retrieving a token


I am testing FedCM since third-party cookie is phasing out. I've implemented Google OneTap sign-in successfully for years for my website. You can verify it from live website. I am now testing opt-in FebCM. In my browser, this setting is enabled: Sites can show sign-in prompts from identity services. For third-party cookies, this option is selected: Block third-party cookies.

I've added the data attribute accordingly:

<div id="g_id_onload" data-client_id="***.apps.googleusercontent.com" 
data-login_uri="https://localhost:50001/account/external-login-google-one-tap?rurl=~%2F" 
data-use_fedcm_for_prompt="true">
</div>

When click the prompt sign-in button after page is loaded, I am getting error: error image

Error:

When fetching the id assertion endpoint, a 403 HTTP response code was received.
localhost/:1 Provider's token is invalid.
client:48 [GSI_LOGGER]: FedCM get() rejects with IdentityCredentialError: Error retrieving a token.

Solution

  • I experienced the exact same problem. It just so happens that the javascript origins were not matching. Make sure that your client has the javascript origins properly configured in the credentials screen of your GCP project. If you are testing in localhost, if you are using, for example, localhost:3000, make sure to include in the javascript origins "http://localhost" and "http://localhost:3000", otherwise it wont work. After saving the changes it might take some time to propagate but it should work.