Skip to content

Unlink a custom account

Unlink the custom account from the currently logged-in Player ID. After unlinking, the user cannot log in to this Player ID with that custom account. First check whether the user can also log in with another login method.

To unlink a custom account, use UnlinkProviderAsync(), the method for unlinking login methods. If you specify the custom account in ProviderId of the request, the custom account linked to the current Player ID is unlinked.

Before you call it, the user must be logged in with the session activated. Unlinking is processed based on the Player ID of the current session.

Method

UnlinkProviderAsync

Call UnlinkProviderAsync() to unlink the custom account from the current Player ID.

Call parameters

Field name Type Required Description
request ProviderUnlinkRequest Required Login method unlinking request
context ApiCallContext Optional Per-call settings object. If omitted, the default values are used.

ProviderUnlinkRequest

Field name Type Required Description
ProviderId Provider Required Login method to unlink. For a custom account, specify CustomProvider.

Call example

For the result model and handling principles of common failures (Failure) that prevent the request from being performed, see Common error handling.

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

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

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

switch (result)
{
    case AuthUnlinkProviderResult.Success:
        // Unlinking complete → refresh the linking status screen
        break;

    case AuthUnlinkProviderResult.ProviderNotExist:
        // No custom account is linked to the current Player ID
        break;

    case AuthUnlinkProviderResult.LastProviderUnlinkBlocked:
        // Cannot unlink because it is the last remaining login method
        // Guide the user to link another login method first
        break;

    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

On success, Data (VoidResponseData) of AuthUnlinkProviderResult.Success contains no values to use. If the result branches to Success, the unlinking has been processed.

If you need to refresh the linking status screen immediately, update the list of login methods that the app keeps yourself, or display it again based on Data.ProviderList in the next login response.

Response status

We recommend handling the response cases of AuthUnlinkProviderResult with a switch statement.

Response case Description App client handling
Success Unlinking succeeded Refresh the linking status screen
ProviderNotExist The login method is not linked to the current Player ID Check the latest linking status
LastProviderUnlinkBlocked The login method cannot be unlinked because it is the last one remaining Guide the user to link another login method first
GuestUnlinkBlocked Guest was specified in ProviderId. Guest cannot be unlinked. Check the requested ProviderId value
ProviderNotSupported An undefined ProviderId value was requested Check the requested ProviderId value
AppIdMismatch The app information in the request differs from the app information of the session Check the SDK initialization status
InvalidGatewayContext The authentication information is not included in the request Check the session activation status
IpBlocked The access IP is blocked Inform the user of the policy
AppNotFound The app information cannot be found Check the app registration status in the console
TerminateService The app's service has ended Check the service operation status
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 stored in Failure.Problem.ExternalCode. See Common error handling. Handle according to the common error handling criteria

Next steps