How does useLogin with custom authProvider?
I want use custom authProvider and login.
5 Replies
Hi @xiaoming. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To use a custom
authProvider
with useLogin
in Refine, you need to define the login
method in your authProvider
and then use the useLogin
hook in your component.
Here's how you can define the login
method in your authProvider
:
(Source: refine.dev (https://refine.dev/docs/tutorial/understanding-authprovider/create-authprovider#login))
Then, you can use the useLogin
hook in your component like this:
(Source: refine.dev (https://refine.dev/docs/tutorial/understanding-authprovider/create-authprovider#login))
Remember to pass your authProvider
to the <Refine/>
component as a prop:
(Source: refine.dev (https://refine.dev/docs/tutorial/understanding-authprovider/index#using-auth-providers-in-refine))
This way, when you call mutate
from useLogin
, it will execute the login
method from your authProvider
with the provided parameters.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@767617717385429022> kapa.ai is still learning and improving, please let us know how it did by reacting below
robust-apricot•8mo ago
Is there api reference documentation of refine v4? @kapa.ai
foreign-sapphire•8mo ago
Hello @xiaoming here is the documentations of how to create authProvider from scratch
https://refine.dev/docs/tutorial/understanding-authprovider/create-authprovider/
https://refine.dev/docs/guides-concepts/authentication/
robust-apricot•8mo ago
Thanks, I messed up the code, it finally worked.