I am currently using Firebase Authentication in my app and have successfully implemented email/password login functionality. Now, I am trying to add Google OAuth2 sign-up and sign-in capabilities.
I have been following the official Firebase REST API documentation:
https://firebase.google.com/docs/reference/rest/auth?hl=en#section-sign-in-with-oauth-credential
According to the documentation, the following request should be sent:
curl 'https://identitytoolkit.googleapis.com/v1/accounts:signInWithIdp?key=[API_KEY]' \ -H 'Content-Type: application/json' \ --data-binary '{"postBody":"id_token=[GOOGLE_ID_TOKEN]&providerId=[google.com]","requestUri":"[http://localhost]","returnIdpCredential":true,"returnSecureToken":true}'
My question is, where and how can I obtain the id_token
value in the postBody
of this request example?
As mentioned, I am trying to implement both sign-up and sign-in using Google OAuth2.
I have attempted to obtain the Access Token using the following request and use it as the id_token
value (replacing [GOOGLE_ID_TOKEN]
) in the postBody
:
I have configured the necessary credentials in the Google Cloud Console.
However, when I make this request, the following message is displayed in the web browser:
Unable to process request due to missing initial state. This may happen if browser sessionStorage is inaccessible or accidentally cleared. Some specific scenarios are - 1) Using IDP-Initiated SAML SSO. 2) Using signInWithRedirect in a storage-partitioned browser environment.
This issue occurs in both Android and Windows Chrome.
Below are my blocks. The blocks inside AfterActivity are not executed. In case you are wondering, the reason I used WebViewer was to test if I could extract the required values by setting the homeurl of the WebView to redirect_uri. Also, the blocks inside WebViewStringChange are not executed.
I am wondering if I am following the correct approach and if I am missing any steps.
Could you please provide guidance on this matter?
Thank you for your assistance.