Deeplink setup
Set up the login deep link on the App Login page in Stash Studio. Use a URL scheme that clearly represents your game, and register it in your game client on each platform. For example, the demo app useshowlingwoods://.
1
Open App Login
Open your game in Stash Studio. In the main menu, click Webshop, then App Login.
2
Turn on App Login
Turn on Enable App Login and enter a Button label. Players see a “Sign in with” button with that label.
3
Enter the login deep link
In Login deep link, enter your app’s deep link with
%s where the login code goes, for example yourscheme://stash/login?code=%s. Use %s exactly once. This is not the Account Linking URL scheme.4
Set a minimum app version (optional)
In Minimum app version (optional), enter the oldest app version that can sign in, as numbers separated by dots, for example
2.37.0. Stash declines a login from an older version with CLIENT_OUTDATED and the minimum version, so your game can ask the player to update. Leave it empty for no minimum. See When Stash declines an outdated app.To require a different version on one platform, also fill in Minimum iOS app version (optional) or Minimum Android app version (optional). A platform’s own minimum applies to players on that platform instead of Minimum app version. Leave a platform field empty to use Minimum app version there.Stash picks the minimum for the platform your game server sends with the login. When no platform is sent, Minimum app version applies.5
Save
Click Save. Changes are live on your web shop right away. On desktop, players scan a QR code that opens the QR landing page shown on the same page, which then opens your app.
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.1
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.
2
Extract the Code
Parse the deep link or callback URL to extract the
code parameter.3
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.ApproveCustomLogin.
Login code rules
- Lifetime. A code is valid for 10 minutes from when the webshop creates it. Approve it inside that window.
- Single use. A code can be approved once.
- Format. The code is URL-safe base64 and can end in
=. Pass it toApproveCustomLoginexactly as it appears aftercode=in the link.
ApproveCustomLogin answers:
After approval
AfterApproveCustomLogin returns 200, the webshop page that showed the code finishes the sign-in. It keeps checking for the approval while the player has it open, so the game only has to get the player back to that page.
1
Don't open the webshop
Don’t open the webshop URL from the game after approval. That loads a new page, often in a new tab, and a new page can’t finish the sign-in: only the page that created the code completes it.
2
Send the player back to the browser
Show a message in the game asking the player to switch back to their browser. This works on every platform and browser. Where your platform can bring the browser back to the front without opening a page, the game can do that as well.
3
The webshop signs the player in
Back on the page, the player is signed in within a few seconds, as long as the code is still inside its 10-minute lifetime.
On desktop, the player scans the QR code with their phone and the page that showed the code stays open on the computer. The game approves the code as usual and opens nothing; the page on the computer finishes the sign-in.
Decline a login
When your game won’t sign the player in to the webshop, callDeclineCustomLogin (POST /sdk/custom_login/decline) from your game server instead of approving the code. Send the login code and a reason. A declined code can’t be approved, and repeating the decline with the same reason succeeds again.
For every reason, the webshop doesn’t sign the player in. It shows the player a short message for the reason you sent, in the page’s language:
The message gives no detail beyond that. Tell the player in your game why the webshop isn’t available to them.
Each decline sends a
LOGIN_FAILED webhook with declinedBy set to "PARTNER".
Turning the webshop off for every player at once is a separate setting, not a
reason your server sends: put your webshop in maintenance mode. While it’s on, players see a maintenance page and can’t sign in or buy.When Stash declines an outdated app
Stash declines a login itself, withCLIENT_OUTDATED, when all of these hold:
- Your shop has a minimum app version.
- Your server sends the player’s app version as
user.clientVersion. - That version is below the minimum that applies to the
user.platformyour server sends. With no platform, Minimum app version applies.
user.clientVersion, Stash doesn’t check the version.
The declined call still returns 200, with a decline object in place of its usual result:
Declined ApproveCustomLogin response
decline.minAppVersion, when present, is the minimum that applied to the player. Show the player an update prompt in your game, with that version when you have it. A declined code stays declined, so after updating the player starts sign-in again from the webshop.
After an ApproveCustomLogin decline, the webshop also shows the player its CLIENT_OUTDATED message, naming the minimum version, as it does for a decline your server sends.
A Stash decline doesn’t sign the player out. Only a decline your server sends with DeclineCustomLogin can (see Sign the player out with the decline).
A Stash decline sends a LOGIN_FAILED webhook with declinedBy set to "STASH".
Sign the player out with the decline
ADeclineCustomLogin that carries the player’s userId also signs the player out of the webshop on every device, as LogoutUser does.
- Send the player’s ID in your game as
userIdin the decline. A decline withoutuserIdsigns no one out. - The sign-out is best effort: the decline succeeds even when the player can’t be signed out.
Sign a player out
LogoutUser (POST /sdk/server/custom_login/logout) signs the player out of the webshop on every device. It also refuses every login code and pre-authenticated link issued for that player before the call, including a code you approved a moment earlier.
Before you call LogoutUser, check whether one of these cases fits:
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:1
Download the SDK
2
Import the package
Import the
.unitypackage file into your game with the Unity asset package import process.3
Import demo scenes (Optional)
Select the
Scenes folder to import demo scenes.Set up deep links
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
Extract the code
With deep linking configured, you can extract the code. Use Unity’sApplication.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