# Nintendo Switch

We have made authenticating with Nintendo Switch as simple as possible with this integration.

#### Register a Session

Ensure that you have the following conditions met:

* You are registered with Nintendo as a developer (otherwise you will not have access to their developer tools)
* Install the Nintendo Dev Interface (obtained from [developer.nintendo.com](https://developer.nintendo.com)) and set up an environment that matches your Unity version
* Install the NintendoSDK from the environment, as well as all dependencies
* You have enabled the Nintendo Switch platform in your games settings in LootLocker, and the Nintendo Application ID matches in your editor and the LootLocker console (You can use the Nintendo default one during initial development)

{% hint style="info" %}
Note that we can not guide you on how to obtain the `NSAIDToken`for the example below due to legal reasons. The NintendoSDK does have great examples on how to obtain this yourself though.
{% endhint %}

{% tabs %}
{% tab title="Unity" %}
{% hint style="warning" %}
This requires that you have [set up the Unity SDK in your game.](/the-basics/unity-quick-start.md)
{% endhint %}

We'll start by creating a new empty Game Object in your scene and calling it GameManager. Feel free to skip this if you already have a GameManager or similar in your game.

![](/files/IInMmSCjZSq8F3wTAJq5)

Then in this new GameObject you can add a new script called GameManager

![](/files/owQYNpNSIHeKP2fB39qn)

Open up your new script in your editor of choice and add the following code.

```csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using LootLocker.Requests;

public class GameManager : MonoBehaviour
{
    void Start()
    {
        string NSAIDToken = getNSAIDToken();
        LootLockerSDKManager.StartNintendoSwitchSession(NSAIDToken, (response) =>
        {
            if (!response.success)
            {
                Debug.Log("error starting LootLocker session");

                return;
            }

            Debug.Log("successfully started LootLocker session");
        });
    }
}
```

To confirm that everything is running without errors, you can start your game and check the console for the correct Debug.Log message.
{% endtab %}

{% tab title="Unreal" %}
​

<figure><img src="/files/5g5BeP66stSlJdCwO31Y" alt="Blueprint example of starting a session with a Nintendo Switch Player - https://blueprintue.com/blueprint/e190bbsq/"><figcaption><p>​<a href="https://blueprintue.com/blueprint/e190bbsq/">Blueprint example of starting a session with a Nintendo Switch Player</a>​</p></figcaption></figure>

To copy and paste the above example into your editor, [look here](https://blueprintue.com/blueprint/e190bbsq/).

**Input**

You need to exchange the `TriggerNintendoStartSession` event for whatever event you want to use to trigger the login flow.

Remove the node `REPLACE: NSA Id Token` so that you provide the actual Nintendo Switch Token.

**Output**

We recommend branching the completed events on the success flag, and if you do this you will probably want to add error handling in case the request fails as well as what (if any) continued actions you want on success.
{% endtab %}

{% tab title="REST" %}

```bash
curl -X POST "https://api.lootlocker.io/game/session/nintendo-switch" \
  -H "LL-Version: 2021-03-01" \
  -H "Content-Type: application/json" \
  -d "{\"game_key\": \"your_game_key\", \"nsa_id_token\": \"eyJQa....\", \"game_version\": \"1.0.0.0\", \"session_id\": \"8438f4b3-90e4-4cdd-8434-c5c6b4c2c9f1\"}"
```

Example response:

```json
{
  "success": true,
  "session_token": "e6fa44946f077dd9fe67311ab3f188c596df9969",
  "player_id": 3,
  "public_uid": "TSEYDXD8",
  "player_created_at": "2022-05-30T07:56:01+00:00",
  "check_grant_notifications": true,
  "check_deactivation_notifications": false,
  "seen_before": true
}
```

{% endtab %}
{% endtabs %}

{% hint style="success" %}
Congratulations - you have now started using LootLocker in your game with Nintendo Switch! Next up we suggest you look at our [feature set,](/the-basics/what-is-lootlocker.md#overview) and decide which ones you want to use in your game.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lootlocker.com/players/authentication/how-to/nintendo-switch.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
