Unable to create login page following refine doc for Azure AD
I'm following Refine doc (Azure Active Directory B2C (AAD B2C))[https://refine.dev/docs/advanced-tutorials/auth/azure-ad/#installation]. Currently I got an error when creating the login.tsx. The error is
and the offending line is
login()
below, copied from the docs:
Please helpAzure AD Login | refine
Azure Active Directory B2C provides business-to-customer identity as a service. Your customers use their preferred social, enterprise, or local account identities to get single sign-on access to your applications and APIs.
12 Replies
Hi @stelarinc. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The error message you're seeing suggests that the
login
function is expecting 1-2 arguments, but none were provided. This is likely because the login
function, as part of the useLogin
hook, expects an object with the user's credentials (like username and password) as an argument.
In the Refine documentation (https://refine.dev/docs/tutorial/understanding-authprovider/create-authprovider), there's an example of a login
function that takes an object with email
and password
properties as an argument:
In your case, you might need to modify your login
function call to include these arguments. However, without knowing more about your specific implementation, it's hard to provide a more specific solution.
You might want to refer back to the Refine documentation (https://refine.dev/docs/tutorial/understanding-authprovider/create-authprovider) or the useLogin documentation (https://refine.dev/docs/api-reference/core/hooks/authentication/useLogin/) for more information on how to use the login
function.
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@1066527438663860284> kapa.ai is still learning and improving, please let us know how it did by reacting below
flat-fuchsiaOP•2y ago
@kapa.ai , I'm following the exact Refine Azure AD documentation which doesn't include any arguments in the
login()
, Am I missing a step or does the documentation require update?Let me check the knowledge base for you. One moment! :books:
----------------------
The
login
function in the useLogin
hook doesn't necessarily require arguments. However, it can accept an object as an argument, which can be used to pass in user credentials or a custom URL for redirection after login.
In the Refine documentation (https://refine.dev/docs/api-reference/core/hooks/authentication/useLogin), there's an example of using the login
function with user credentials as arguments:
And another example of using the login
function with a custom URL for redirection:
In your case, the login
function is being called without any arguments:
This should be fine as long as your login
method in the authProvider
doesn't require any arguments. If your login
method does require arguments, you'll need to modify your login
function call to include these arguments.
If you're still encountering issues, it might be a good idea to double-check your authProvider
and make sure it's set up correctly. You can refer to the Refine documentation (https://refine.dev/docs/advanced-tutorials/auth/azure-ad) for more information on setting up the authProvider
.
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------<@1066527438663860284> kapa.ai is still learning and improving, please let us know how it did by reacting below
flat-fuchsiaOP•2y ago
Is there a working github example of refine with Azure AD authentication / authorization?
correct-apricot•2y ago
Hey @stelarinc,
By default, the login method is not expect any arguments. It's weird, can you provide more information about your problem? What is the error message? What is the code you are using? Or can you provide a codesandbox example to reproduce the problem?
flat-fuchsia•2y ago
hey @stelarinc i do it with this example coming from another framework react based : https://github.com/marmelab/ra-auth-msal
AZURE AD implement by defaut the MSAL AUTH
flat-fuchsiaOP•2y ago
@salihozdemir I got the error as per my original first post. I followed the refine official tutorial to create refine app and subsequently the first thing I did was to change the auth provider to Azure AD. And thats where I got the error. Im pretty new to codesandbox and the like. Will try to find out how to do if I'm still stuck at this stage.
@berdailabs thanks. Will try it out and update.
inland-turquoise•2y ago
Hi @stelarinc , sorry for this problem. I think there is a bug in our document. Let us check and get back to you 🚀
Hi @stelarinc, I could not reproduce the problem you are having. However, I can suggest passing an empty object to the
login
method.
Hi @stelarinc Do you have any updates for that?flat-fuchsiaOP•2y ago
I tried with giving login an empty object, but it still giving error. Im still trying to use MS docs to perform the authentication. It seems to work but there're some other issues that Im troubleahooting (issue with msal rather than with refine itself)
Nevertheless, I tried to redo the refine app from the start and immediately following that I followed the refine docs for AD authentication. I arrived at the same issue
inland-turquoise•2y ago
We could not reproduce the same problem. We have no experience with Azure AD. Can we open a test account and get this information?
I believe if we can reproduce the problem, we will solve the problem.