Class UserManager

Manages the current user. Current user changes as user login and logout.

Multiple instances of this class can be used to manage multiple current user. For example, running multiple clients in same application.

Inheritance

System.Object
UserManager

Inherited Members

System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ToString()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: StreamSIX.Auth
Assembly: cs.temp.dll.dll

Syntax

public class UserManager

Fields

UserChanged

Triggers when current user change. This is static so will trigger for any instance of UserManager

Declaration

public static Action<User> UserChanged

Field Value

TypeDescription
System.Action<User>

Properties

CurrentUser

The current user. This object changes as user login and logout.

Declaration

public User CurrentUser { get; }

Property Value

TypeDescription
User

Methods

AddLoggingHeaders(HttpRequestMessage)

Adds logging headers.

x-transaction-id is random guid that's unique to this request

x-session-id is the current session ID. Call SetSession(String) to set this up.

x-license is the license for this game. Call SetLicense(String) to set this up.

Declaration

public void AddLoggingHeaders(HttpRequestMessage request)

Parameters

TypeNameDescription
HttpRequestMessagerequest

AddStandardHeaders(HttpRequestMessage)

Adds authentication and logging headers. Calls this before sending any request to the platform. If credentials is about to expire, this will refresh token before adding to header.

Declaration

public async Task AddStandardHeaders(HttpRequestMessage request)

Parameters

TypeNameDescription
HttpRequestMessagerequest

Returns

TypeDescription
Task

GetUserType()

Return current user type

Declaration

public UserType GetUserType()

Returns

TypeDescription
UserType

LoginWithEmailAsync(String, String)

Login to an existing account

Declaration

public async Task LoginWithEmailAsync(string username, string password)

Parameters

TypeNameDescription
System.Stringusername

user name

System.Stringpassword

password

Returns

TypeDescription
Task

Exceptions

TypeCondition
LoginException

Message contains description of error.

LoginWithIDPTokenAsync(String, String, String)

Login by the IDP token.

Backend grab the email from the IDP token, and if an account with that email exists, then it'll link to that account and log you in.

Otherwise, it'll automatically create a new account, link to that account, and log user in.

Declaration

public async Task LoginWithIDPTokenAsync(string issuer, string tokenType, string idpToken)

Parameters

TypeNameDescription
System.Stringissuer

Various OIDC providers: twitch|google|apple|facebook|etc...

System.StringtokenType

This can differ per issuer. See Keycloak API for details.

System.StringidpToken

Access token from OIDC provider which indicates the user's account.

Returns

TypeDescription
Task

Exceptions

TypeCondition
LoginException

LogoutAsync()

Logout current user and switch to a guest user

Declaration

public async Task LogoutAsync()

Returns

TypeDescription
Task

Exceptions

TypeCondition
LogoutException

SetLicense(String)

Sets this game's license for logging purpose.

Declaration

public void SetLicense(string license)

Parameters

TypeNameDescription
System.Stringlicense

SetSession(String)

Sets current session id for logging purpose.

Declaration

public void SetSession(string session)

Parameters

TypeNameDescription
System.Stringsession

SetUserType(UserType)

Sets user type which represent what application is user using

Declaration

public void SetUserType(UserType userType)

Parameters

TypeNameDescription
UserTypeuserType