Get supported login methods
GetProviderListAsync
To decide which login buttons to show on the login screen, call GetProviderListAsync(). You call this method before login, so it does not need a session. Call it right before drawing the login screen, and build the login buttons according to the returned list.
The Hive Axyl authentication server applies all of the following conditions and returns the list of login methods that this app can use right now. The app client does not pass these conditions separately, and the app cannot specify the country either.
- Service environment: Login methods available for the combination of the runtime environment and the distribution store bound to the App ID
- Console login settings: Login methods turned on in the login settings of the Hive Console
- Country: Some login methods excluded depending on the country determined from the request IP
Call parameters
| Field name | Type | Required | Description |
|---|---|---|---|
| context | ApiCallContext | Optional | Per-call settings object that specifies the idempotency key, cancellation token, and request policy. If omitted, the default values are used. |
Call example
The return object of GetProviderListAsync(), AuthGetProviderListResult, is divided into success, Outcome (feature-specific results), and Failure (the call could not be completed). This method does not throw exceptions and delivers every processing result through the return object, so branch with a switch statement instead of try/catch.
using Hive.Axyl.Auth;
using Hive.Axyl.Core;
using UnityEngine;
// auth: IAuthService registered during module initialization
IAuthService auth = HiveCore.Resolve<IAuthService>();
AuthGetProviderListResult result = await auth.GetProviderListAsync();
switch (result)
{
case AuthGetProviderListResult.Success success:
// Show only the returned login methods on the login screen.
foreach (ProviderItem provider in success.Data.ProviderList)
Debug.Log($"[LoginUI] Show the {provider.ProviderId} button");
break;
case AuthGetProviderListResult.ProviderConfigNotFound:
// No login methods are configured for this app in the console.
Debug.LogError("Check the login settings in the console.");
break;
// Handle common failures (network and server errors)
case AuthGetProviderListResult.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, the result is contained in Data of AuthGetProviderListResult.Success.
| Variable name | Type | Required | Description |
|---|---|---|---|
Data.ProviderList | IReadOnlyList<ProviderItem> | Required | List of login methods this app can use right now |
ProviderItem
| Variable name | Type | Required | Description |
|---|---|---|---|
ProviderId | Provider | Required | Login method identifier. One of Guest, Google, SigninApple, GooglePlayGames, Steam, X, Username, and CustomProvider. |
ProviderIndex | int | Required | Numeric identifier that represents the login method |
Response example
Response status
The return object AuthGetProviderListResult branches into one of the following cases.
| Response case | Description | App client handling |
|---|---|---|
Success | Retrieval succeeded. Data.ProviderList contains the list. | Build the login buttons according to the list |
AppNotFound | The app information cannot be found | Check the App ID registration status in the console |
ProviderConfigNotFound | No login methods are configured for this app | Check the login settings 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 |
Related documents
- Log in with an external authentication provider: Implementing Google, Apple, Google Play Games, Steam, and X account login
- Get started - Log in: Implementing guest account and username account login
- Link accounts and get linked login methods: Checking the login methods linked to the current account