Login_hint param is always empty when using ULP with reactjs

I have this code where I set the login_hint param dynamically & coming from user input. But when it redirect to /authorize url & i inspect it then the login_hint param is always empty. I can see that the login_hint param is set in the console message when I input any email.

import React, {useState, useEffect} from 'react';
import {createRoot} from 'react-dom/client';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import {Auth0Provider} from '@auth0/auth0-react';
import history from './utils/history';
import {getConfig} from './config';
import {EmailProvider, useEmail} from "./components/EmailContext";

const onRedirectCallback = (appState) => {
    console.log('onRedirectCallback called');
    history.push(appState && appState.returnTo ? appState.returnTo : window.location.pathname);
};

const config = getConfig();

// Custom wrapper component that includes an input for login_hint
const Auth0ProviderWithConfig = ({children}) => {
    const {email, setEmail} = useEmail();

    const providerConfig = {
        domain: config.domain,
        clientId: config.clientId,
        onRedirectCallback,
        authorizationParams: {
            login_hint: email,
            redirect_uri: window.location.origin,
            ...(config.audience ? {audience: config.audience} : null),
        },
    };
    console.log(providerConfig.authorizationParams)
    

    return (

        <Auth0Provider {...providerConfig}>
            {children}
        </Auth0Provider>

    );
};

const root = createRoot(document.getElementById('root'));
root.render(
    <EmailProvider>
        <Auth0ProviderWithConfig>
            <App/>
        </Auth0ProviderWithConfig>,\
    </EmailProvider>
);

serviceWorker.unregister();

Any help would be appreciated.

Hey there @rm123 welcome to the community!

Which version of auth0-react are using? I just tested in our sample app and see the login_hint param included in the authorize request and subsequently added to the UL email field.

I am using "@auth0/auth0-react": "^2.2.0" which is the latest version present in the sample app as I am using the sample app with some modifications. The problem is that if hardcode the login_hint param in authorizationParams then it works but if I want this to come from the some input field as I have done in the code I have posted then it does not work.

I am also using the react-devtools to check if the state & the Auth0Provider does reflect the updated login_hint value (Check the screenshot below) but when it redirects then the URL field is empty I don’t know why.

1 Like

@tyf can you please help me with this? I am still not able to solve this problem.

1 Like

Hey @rm123 , thanks for further clarifying!

Have you tried to use loginWithRedirect to pass the login_hint param?