Reputation:
Based on the Firebase Auth documentation, I can set custom parameters using the setCustomParameters
method on the GoogleAuthProvider
Looking at the parameters accepted by Google's OAuth 2.0 authentication API, it indicates that the state
parameter is "an opaque string that is round-tripped".
I am setting the value:
googleAuthProvider.setCustomParameters({state:"myValue"});
And I can see that is gets added to the URL in the redirect when calling:
await signInWithRedirect(auth, googleAuthProvider);
However, after authenticating, I do not see any value added to the redirect URL which returns the users to my page.
How can I read the value I passed in to "state"?
Upvotes: 0
Views: 318
Reputation: 18595
The .onAuthStateChanged
event will fire. This is what drives the state of your app/webapp. In terms of getting or reading the state
custom parameter, it gets returned to your app via the redirect uri as state=THE_STATE_PARAMETERS
.
Sets the OAuth custom parameters to pass in a Google OAuth request for popup and redirect sign-in operations.
auth.onAuthStateChanged(function(user) { ...
Upvotes: 1