Skip to main content

Android Authentication

You can use MetX Authentication to allow your players to sign in to your game using MetX Gamer App. This tutorial gets you started with MetX Authentication by showing you how to add sign-in to your Android game.

Integrate MetX Games platform's sign in by following the below snippet. This generates an auth token that you can use to identify your MetX Games players in-game. This auth expires in two hours.

This URI accepts two parameters:

  • gameId which is your game's identifier.
  • redirect deeplink where we can pass the auth token to. More info on Unity deeplinking
info

redirect can only be deeplinks. Deep links are URL links outside of your application that direct users to a location in your application. These should look like appname://

We currently do not support redirect links to external websites.

In the below snippet, we're building a sign in link for an android game.

public string BuildSignInString() 
{
string gameId = "C738460CA5F3A923"; //The game's game Id.
string redirect = "tt:%2F%2Fauth"; //Deeplink to pass the `auth` to.

string authenticationURL = $"https://test-games.metaxar.io/android-auth/{gameId}/{redirect}";

return authenticationURL;
}

//This returns https://test-games.metaxar.io/android-auth/C738460CA5F3A923/tt:%2F%2Fauth

Clicking on this link will lead you to the MetX platform where you can sign in normally. After signing in, you will be returned to the game with an auth parameter. You can use the auth to retrieve information about the user and send them airdrops, transaction requests, etc. More info here

note

The returned auth is a volatile string used to identify your players. This can retrieve the username, profile photo, wallet address of the user and can testify the identity and wallet ownership of that user. auth does not have any authoritative priviledges of the user account, and can be revoked at any time.

Once the deeplink reopens your game, you can parse the auth like this:

public string GetAuthFromDeeplinkParam(string deeplink) 
{
return url.Split("?"[0])[1].Split("=")[1];
}

Here's how it looks like in action:

Try it out​

Once a player signs in, an auth parameter will be passed to the destination of redirect. You can aquire auth for testing by signing into a MetX Games account, and then copying the auth parameter here!