Select social provider with Auth0 React SDK

Hi Everyone,

I’m using the React SDK for logging to my SPA. I have my own custom login page and I want to login with google. However, it first directs me to the Auth0 login page where you can log in with google, and then it directs me to google to actually log in. I want it to immediately go to the google login page, and skip the login page Auth0 provides. I was able to do this using “WebAuth” from auth0-js like this:

let webauth = new WebAuth({
domain: <DOMAIN_NAME>,
responseType: “token”,
clientID: ,
redirectUri:
});

function authorizeLogin() {
webauth.authorize({
connection: ‘google-oauth2’
});
}

Now that I’m using the React SDK, the only thing I can control is what I’m destructing with the useAuth0:

const {
isLoading,
isAuthenticated,
error,
user,
loginWithRedirect,
logout,
} = useAuth0();

I can only use the loginWithRedirect, but is there a way to edit the loginWithRedirect in a way that redirects me immediately to the google login?

Thanks in advance.

Best regards

Hi @katab,

If you pass {connection:"google-oauth2"} it should redirect directly to google login.

I just tested this and got it working.

Let me know if you have questions.
Dan

Hi @dan.woda,

It works thank you!

One typo I found in your comment: you said {connection:"google-oauth2} it should be {connection:“google-oauth2”} (you forgot an apostrophe at the end). :wink:

Greetings,

Katab

Thanks for letting me know! I updated the post :smile_cat:

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.