Closed ropali-munshi closed 6 months ago
You want to do this when calling loginWithRedirect
and set the login_hint
on authorizationParams
in that function. The properties of the Auth0Provider do not support being changed over time.
@frederikprijck Is there any other way to do that? I don't understand why it does not support that. the only way to use login_hint
is to use the hardcoded value which does not make much sense to me.
the only way to use login_hint is to use the hardcoded value which does not make much sense to me.
The way to use a dynamic login_hint is to pass it to loginWithRedirect({ authorizationParams: { login_hint: sessionStorage.getItem("userInputEmail") }})
. That should allow you to achieve what you want without having to rerender the Provider when the value changes.
@frederikprijck Thanks! It is working properly.
Checklist
Description
I am trying to use the
login_hint
inauthorizationParams
. I have a requirement of setting this param dynamically so that when the user goes to the auth0 login page then the email is prefilled. This works if I use a hardcoded value but fails when using a local/global state to populate that parameter.I can see the
login_hint
param is set in theAuth0Provider
component when the state changes using the Reactjs component debugger but when I call theloginWithRedirect()
the/authorize
URL haslogin_hint
value empty. I have posted this issue in the Auth0 community forum here https://community.auth0.com/t/login-hint-param-is-always-empty-when-using-ulp-with-reactjs/127953 with code sample.I also tried to use session storage to see if this works or not. So when a user enters an email I store it in the session storage & try to fetch the value from it in the
authorizationParams
. It actually works sometimes & sometimes not.Here is the code example
Reproduction
Try to fill the
login_hint
param in theauthorizationParams
dynamically using either state variable or session storage.Additional context
I am using Vite with Typescript for building the project.
auth0-react version
2.2.4
React version
18.2.0
Which browsers have you tested in?
Chrome