Login
This method is only relevant if you are not using Metafi SSO login. If you are using Metafi SSO, you do not need to implement this function. This function does not trigger a UI modal.
This function should be called whenever a new JWT token is issued to the user when they first log in, when a refreshed token is issued, or if the user is switched. This JWT will be authenticated via a webhook endpoint that you will provide, and only once validated can the user access their wallet.
Login(userIdentifier, token, callback)
Parameter | Type | Definition |
---|---|---|
userIdentifier | String | The unique user ID for the current player.
Please ensure that this userIdentifier matches the value returned by your verification endpoint. |
token | String | The encoded JWT token issued to the user. |
callback? | Function | A callback function that will be executed once the user is successfully logged in. The callback function will return a data structure similar to that returned by the RetrieveUser function |
None
You can update your JWT verification URL on the Developer Portal under the Project Settings menu.
When the Login function is invoked, we will invoke the configured JWT verification URL with the token passed to us in the Login function in the body. The response must be the userIdentifier of the user to which you want the user's wallet to be linked to.
The endpoint must implement the following format:
post
https://your-webhook-url
/path
1
import { useMetafi } from '@metafi/metafi-react-package';
2
import { handleLogin } from './login-controller'
3
4
export const LoginComponent = () => {
5
const { Login } = useMetafi();
6
7
const onLogin = () => {
8
var jwtToken = handleLogin(); // your logic to login user
9
Login("[email protected]", jwtToken, (result, error) => {
10
console.log("received the following from login", result, error)
11
});
12
}
13
14
return <>
15
<button onClick={onLogin}>Login</button>
16
</>
17
}
Last modified 6mo ago