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.

Description

This function should be called whenever a new JWT token is issued to the user when they first log in, 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.

Details

Signature

Task Login(string userIdentifier, string token, System.Action<dynamic> callback = null)

Arguments

Return Value

None

JWT Verification Endpoint

You can update your JWT verification URL on the Developer Portal under the Project Settings menu.

Here is a sample repo containing sample code for the JWT verification endpoint.

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

Request Body

{
    "userIdentifier": "userIdentifier"
}

Example

using System;
using Metafi.Unity;

public class GameManager : MonoBehaviour {
    public async void Login(string userIdentifier, string jwtToken) {
        await MetafiProvider.Instance.Login(
            userIdentifier, 
            jwtToken, 
            ((System.Action<dynamic>) (result => {
                Debug.Log("Login complete, result: " + result.ToString());
        })));  
    }
}

Last updated