Skip to content

Unlink accounts

Method

UnlinkProviderAsync

To remove one login method from the currently logged-in Player ID, call UnlinkProviderAsync(). Use it when the user cleans up an account they no longer use, or when the user first removes an existing link to switch to another account of the same type.

The following policies apply to account unlinking.

  • Unlinking is possible only while logged in
  • At least one login method must remain after unlinking
  • Guest cannot be unlinked

Guest is not counted among the login methods that remain after unlinking. For example, if you unlink Google from an account linked only to Google and guest, the user would have no way to log in again, so the Hive Axyl authentication server rejects the request. You can also unlink the login method used for the current login if another login method remains.

Custom accounts are also unlinked with the same method by specifying CustomProvider in ProviderId. For information that applies only to custom accounts, see Unlink a custom account.

Call parameters

Field name Type Required Description
request ProviderUnlinkRequest Required Information on the login method to unlink
context ApiCallContext Optional Per-call settings object. If omitted, the default values are used.

ProviderUnlinkRequest

Field name Type Required Description
ProviderId Provider Required The login method to unlink. One of Google, SigninApple, GooglePlayGames, Steam, X, Username, and CustomProvider. Guest cannot be unlinked; if you specify it, the request is rejected with GuestUnlinkBlocked.

Call example

AuthUnlinkProviderResult, the object returned by UnlinkProviderAsync(), is divided into success, Outcomes (feature-specific results), and Failure (the call could not be completed). This method does not throw exceptions and delivers every processing result through the returned object, so branch with a switch statement instead of try/catch.

Unlinking cannot be undone, so show a screen in the app client that asks the user for confirmation before the call.

using Hive.Axyl.Auth;
using Hive.Axyl.Core;
using UnityEngine;

IAuthService auth = HiveCore.Resolve<IAuthService>();

var result = await auth.UnlinkProviderAsync(new ProviderUnlinkRequest {
    ProviderId = Provider.X,
});

switch (result)
{
    case AuthUnlinkProviderResult.Success:
        // Unlinking complete → remove the item from the linking list on the screen.
        Debug.Log("Unlinking completed");
        break;

    case AuthUnlinkProviderResult.LastProviderUnlinkBlocked:
        // Unlinking would leave no way to log in.
        Debug.LogWarning("You cannot unlink the last remaining login method.");
        break;

    // Handle common failures (network and server errors)
    case AuthUnlinkProviderResult.Failure failure:
        HiveError err = failure.Problem;
        Debug.LogError($"[{err.Code}] {err.Message} (trace: {err.TraceId})");
        break;

    // Safety net: unhandled results and unknown new results (UnknownOutcome)
    default:
        Debug.LogWarning($"Unhandled result: {result.GetType().Name}");
        break;
}

Response data

No response data is returned on success. Remove the unlinked login method from the linking list on the screen yourself in the app client.

Response status

The returned AuthUnlinkProviderResult object branches into one of the following cases.

Response case Description App client handling
Success Unlinking succeeded Remove the item from the linking list
LastProviderUnlinkBlocked When unlinking would leave no method to log in with Guide the user to link another login method first
GuestUnlinkBlocked When you try to unlink guest Inform the user that guest cannot be unlinked
ProviderNotExist When you try to unlink a login method that is not linked Update the linking list on the screen to the latest state
ProviderNotSupported When an undefined ProviderId value is requested Check the requested ProviderId value
IpBlocked When the access IP is blocked Inform the user of the policy
AppNotFound · TerminateService When the app information cannot be found or the app's service has been terminated Check the App ID registration status and the service operation status in the console
AppIdMismatch · InvalidGatewayContext When the App ID of the request differs from the project of the authentication token, or the authentication context is invalid Check the App ID used for SDK initialization and the session state
UnknownOutcome A new result that this SDK version does not know Log it and handle it conservatively
Failure Common Failure. Missing required parameters or format errors (invalid_parameter), missing required fields (missing_field), and a missing X-App-Id header (missing_app_id) also branch here, and the cause is contained in Failure.Problem.ExternalCode. See Common error handling. Handle it according to the common error handling guidelines