SSO with passwordless(magic link)

I am trying to implement auth0 SSO and the client wants passwordless magic link as the login method.
I have successfully implemented SSO and it does work when using passwordless CODE and not Magic Link.

When I use the Magic Link method, link is successfully sent to the user but when user clicks on the link, it opens the callback link on a new tab and not on the SSO popup, due to which the SSO cookie is not stored on the popup link due to which user is not able to login. To be precise it throws the status “‘State’ does not match error” which I believe due to the previously mentioned issue.

This is my first time implementing SSO. So I might not have implemented everything perfectly, but if passwordless with code works, I think passwordless with Magic Link should work too.

Any help would be highly appreciated.
Thank you.