Skip to main content

AuthenticationUtility

A class in Alta.Authentication, Alta.Authentication.

Logs the game into the Alta API by refresh token, command line arguments, username and password, or OAuth client credentials. Registered as IAuthenticationUtility in ApplicationLifetimeScope.

Constructors​

MemberWhat it is
AuthenticationUtility(IHighLevelApiClient apiClient, ILoginPreferences loginPreferences)Creates an AuthenticationUtility from apiClient and loginPreferences.

Fields​

3 private and internal fields
MemberWhat it is
private readonly IHighLevelApiClient apiClientThe high-level API client used to log in.
private static readonly Logger loggerNLog logger for this class.
private readonly ILoginPreferences loginPreferencesSaved login preferences, read for the refresh token.

Methods​

MemberWhat it is
async Task<IResult<bool>> LoginWithCommandLineArgumentsAsync()Tries /login, /login_hash, /access_token and /oauth_login in that order. Returns false if none are given.
async Task<IResult> LoginWithCommandLineTokensAsync()Logs in with the /access_token, /refresh_token and /identity_token command line values.
async Task<IResult> LoginWithOAuthAsync(string clientId, string clientSecret, string clientScopes)Logs in with an OAuth client ID, secret and scopes. Semicolons in the scopes become spaces.
async Task<IResult> LoginWithRefreshTokenAsync()Logs in with the refresh token saved in login preferences.
Task<IResult> LoginWithUserPassAsync(string username, string password)Hashes the password and logs in with the username and hash.
2 private and internal methods
MemberWhat it is
private Result<string> GetRefreshToken()Returns the saved refresh token, or an error if remember details is off or no token is saved.
private async Task<IResult> LoginWithUserPassHashAsync(string username, string passHash)Logs in with a username and an already-hashed password. Fails if no user info comes back.