Player Authentication

Account Linking

Learn how to connect a player's webshop session with their game client through account linking. Understand deep link setup, integration steps for different engines, and Unity-specific implementation using the Stash SDK.

Account linking connects a player's webshop session with their game client.

The webshop launches the game through a deep link (on mobile) or a QR code (on desktop). The deep link carries a session code. The game client attaches the player's authentication data to this code and sends both to the Stash API to complete login.

Configure a deep link scheme in Stash Studio. Use a scheme that clearly represents your game. For example, the demo app uses howlingwoods://.

Follow these steps:

Open your game instance

Open your game instance in Stash Studio.

In the main menu, click Webshop.

Configure URL Schemes

Go to Account Linking, then select the URL Schemes tab.

Interactive Demo

Integrate account linking

The example below uses Unity, but you can follow the same flow in other engines such as Unreal Engine, Godot, or custom web/native clients.

Obtain the Player's Authentication Token

Use the platform's authentication system (Google, Apple, or other providers) to retrieve a valid token or credential for the player.

Extract the Code

Parse the deep link or callback URL to extract the code parameter.

Call the Stash Linking Endpoint

Send the code and the player's authentication data to your game server. From there, call ApproveCustomLogin (POST /sdk/custom_login/approve) to complete the link.

ApproveCustomLogin is a server-side endpoint. Call it from your game server, not from the game client directly.

Refer to your engine's documentation for handling deep links. The game client extracts the code and forwards it to your game server. The server completes the link by calling ApproveCustomLogin.

Set up account linking in Unity

Use the Stash SDK to integrate account linking in Unity.

The SDK is optional. It provides convenient wrappers around the API endpoints, but you can also implement account linking with direct API calls.

Import the Stash SDK

Follow these steps to add the Stash SDK to your Unity project:

Import the package

Import the .unitypackage file into your game with the Unity asset package import process.

Import demo scenes (Optional)

Select the Scenes folder to import demo scenes.

See the Unity deep linking overview for platform-specific instructions.

Let's take a look at the structure of the Stash's deep links.

Deep Link Structure
stashggsample://login?code=<code>

The key element in the link is the code. Configure deep links correctly and add logic to extract the code when your game launches through a deep link.

Extract the code

With deep linking configured, you can extract the code.

Use Unity's Application.deepLinkActivated event to handle deep link activations. This event triggers whenever the game launches or resumes from a Stash deep link.

In the onDeepLinkActivated handler, split the link to extract the code.

Extract Code from Deep Link
public void onDeepLinkActivated(string url) {
  // Extract the code parameter from the link.
  var code = url.Split("login?code=")[1];
  if (!string.IsNullOrEmpty(code)) {
    // Work with code...
  }
}

How is this guide?