Next-Auth - Authenticating with provider without needing to press the button generated by next-auth.
Answered
Oak rough bulletgall wasp posted this in #help-forum
Oak rough bulletgall waspOP
I am using NextAuth with App router to Authenticate to my AzureAD B2C instance. I would like to bypass where the user has to press the "Sign in with Azure Active Directory" button (see screenshot) - I would instead just like to take the user straight to our B2C login page. Is this possible?
Answered by Oak rough bulletgall wasp
I was able to do it using nextjs middleware and creating a custom signing page that forced the user to redirect.
4 Replies
just pass the provider as a string to the login function. its clearly stated in the docs
Oak rough bulletgall waspOP
Yeah I read that, however I was trying to redirect to it from a server component, I don’t think I can use signIn from a server component, right?
Oak rough bulletgall waspOP
Additionally, I want to do this without the user having to click a button or anything. I solely want to redirect straight to my B2C sign in page if they have no session.
Oak rough bulletgall waspOP
I was able to do it using nextjs middleware and creating a custom signing page that forced the user to redirect.
Answer