# Disconnect Identity Provider from Player

Sometimes we or the player want to disconnect an identity provider from their account. In this how-to we'll explain how to disconnect a provider from a player's account in a safe manner.

## Prerequisites

Before we begin, ensure you have the following:

* [A game created in the LootLocker web console](https://console.lootlocker.com/)
* An active LootLocker session with multiple connected providers

To learn how to connect providers to a player's account, you can read our documentation on [Connecting Providers to a Player](https://docs.lootlocker.com/players/unified-player-accounts/how-to/connect-provider-to-player)

## List Connected Accounts

We first get a list of connected accounts to see which providers are connected to the player's account.

{% tabs %}
{% tab title="Unity" %}

```csharp
LootLockerSDKManager.ListConnectedAccounts((response) =>
{
    // Optional handling of case where only 1 provider is left on the player
    if (response.connected_accounts.Length == 1)
    {
        Debug.Log("Player has only 1 account connected. Disconnecting this provider will leave the player without any connected providers.");
        return;
    }

    Debug.Log("Player has " + response.connected_accounts.Length.ToString() + " accounts connected.");

    // Log all connected accounts to the console
    foreach (var account in response.connected_accounts)
    {
        Debug.Log("Connected with: " + account.provider_name);
    }
});
```

{% endtab %}

{% tab title="Unreal" %}

<figure><img src="https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-326fc403fb5bf1a4db0b4e0c41f9beba17ad0b1d%2Fue-bp-list-connected-accounts-example.png?alt=media" alt=""><figcaption><p><a href="https://blueprintue.com/blueprint/0vubrhc5/">Blueprint example of listing connected accounts</a></p></figcaption></figure>
{% endtab %}

{% tab title="REST" %}
The reference documentation for this call can be found [here](https://ref.lootlocker.com/game/upa/connected-accounts/list-connected-accounts)

```bash
curl -X "https://api.lootlocker.io/game/v1/connected-accounts" \
    -H "x-session-token: your_token_here"
```

{% endtab %}
{% endtabs %}

## Disconnect Account

{% hint style="warning" %}
When disconnecting providers, we can end up in a situation where the player has no connected providers. Make sure to handle this case in your game, as the player will not be able to log in anymore if all the providers are disconnected.
{% endhint %}

Now we have a list of connected accounts, we can disconnect one of them.

{% tabs %}
{% tab title="Unity" %}

```csharp
// The following providers are supported:
// LootLocker.LootLockerEnums.LootLockerAccountProvider.guest;
// LootLocker.LootLockerEnums.LootLockerAccountProvider.google;
// LootLocker.LootLockerEnums.LootLockerAccountProvider.apple;

// We'll use Apple for this example
var account = LootLocker.LootLockerEnums.LootLockerAccountProvider.apple;

LootLockerSDKManager.DisconnectAccount(account, (response) =>
{
    if(!response.success)
    {
        Debug.Log("Could not disconnect account");
        return;
    }

    Debug.Log("Successfully disconnected account");
});
```

{% endtab %}

{% tab title="Unreal" %}

<figure><img src="https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-6b792a396084ea0eb4e1ad021d69707a079126e4%2Fue-bp-disconnect-apple-example.png?alt=media" alt=""><figcaption><p><a href="https://blueprintue.com/blueprint/vtkfo2vu/">Blueprint example of disconnecting Apple account</a></p></figcaption></figure>
{% endtab %}

{% tab title="REST" %}
The reference documentation for this call can be found [here](https://ref.lootlocker.com/game/upa/connected-accounts/unlink-platform-provider)

```bash
curl -X DELETE "https://api.lootlocker.io/game/v1/connected-accounts/apple" \
    -H "x-session-token: your_token_here"
```

{% endtab %}
{% endtabs %}

## Conclusion

In this how-to we've shown you how to disconnect an identity provider from a player. If you want to learn more, you can read about how to [connect a provider](https://docs.lootlocker.com/players/unified-player-accounts/how-to/connect-provider-to-player) or our general [Unified Player Account](https://docs.lootlocker.com/players/unified-player-accounts) documentation.
