> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stash.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication Methods

> The three ways players sign in to your Stash webshop: pre-authenticated links your game server generates, Direct Sign-in (SSO) with providers like Google, Apple, or Facebook, and Account Linking through deep links and QR codes.

Stash provides three ways for players to sign in to your webshop. You can implement any combination of them.

## Pre-authenticated links

Use a pre-authenticated link when the player starts in your game, for example by tapping a webshop button. The player opens the link and arrives in the webshop already signed in, with no sign-in step.

Your game server calls [Generate authenticated URL](https://docs.stash.gg/api/ingress/server-urls/generateauthenticatedurl.md) (`POST /sdk/server/generate_url`) with the player's `user.id` and a `target`, and receives a `url`. Sign the request with your ingress secret, as described in [HMAC signing](https://docs.stash.gg/guides/get-started/stash-api-keys/overview.md#hmac-signing). Pass the `url` to your game client, which opens it in the browser.

* `target` sets the webshop page the player lands on, for example `STORE` or `LOYALTY`.
* Each link signs a player in once and expires 30 minutes after it is generated. Generate a new link each time the player opens the webshop, and open it right away.
* `user.regionCode` is optional. When you send it, it must be a valid country code; an invalid value rejects the request.

> [!WARNING]
>
> Call `generate_url` from your game server only. Anyone who opens the link before the player can sign in as that player, so do not log, cache, or share it.

## Direct Sign in (SSO)

Players authenticate directly in the webshop using SSO providers such as Google, Apple, or Facebook.

You configure the providers in Stash Studio by adding their credentials. Players click **Sign in**, select a provider, and complete authentication in the browser.

```mermaid theme={null}
sequenceDiagram
actor Player
participant Webshop as Stash Webshop
participant API as Stash API
participant Provider as Identity Provider

Player->>Webshop: Open webshop and initiate login
Webshop->>API: Request authentication with provider
API->>Provider: Redirect or communicate with provider
Provider-->>API: Send auth data + token
API->>Webshop: Validate session and log in user
```

## Account Linking

With account linking, players authenticate by launching your game through a deep link on mobile or by scanning a QR code on desktop.

The deep link passes a session code to the game client. The client attaches the player's authentication data to the session code and sends both to Stash.

This method enables passwordless login by reusing the player's existing game session.

```mermaid theme={null}
sequenceDiagram
actor Player
participant Webshop as Stash Webshop
participant Client as Game Client
participant API as Stash API

Player->>Webshop: Try to log in
Webshop->>Player: Deeplink with session code
Player->>Client: Opens game client using deeplink/QR
Client->>Client: Extract session code + attach player's auth data
Client->>API: Send session code + user auth data
API->>Webshop: Log in player on webshop
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.