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.
Inherited Members
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
Type | Description |
---|---|
System.Action<User> |
Properties
CurrentUser
The current user. This object changes as user login and logout.
Declaration
public User CurrentUser { get; }
Property Value
Type | Description |
---|---|
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
Type | Name | Description |
---|---|---|
HttpRequestMessage | request |
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
Type | Name | Description |
---|---|---|
HttpRequestMessage | request |
Returns
Type | Description |
---|---|
Task |
GetUserType()
Return current user type
Declaration
public UserType GetUserType()
Returns
Type | Description |
---|---|
UserType |
LoginWithEmailAsync(String, String)
Login to an existing account
Declaration
public async Task LoginWithEmailAsync(string username, string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | username | user name |
System.String | password | password |
Returns
Type | Description |
---|---|
Task |
Exceptions
Type | Condition |
---|---|
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
Type | Name | Description |
---|---|---|
System.String | issuer | Various OIDC providers: twitch|google|apple|facebook|etc... |
System.String | tokenType | This can differ per issuer. See Keycloak API for details. |
System.String | idpToken | Access token from OIDC provider which indicates the user's account. |
Returns
Type | Description |
---|---|
Task |
Exceptions
Type | Condition |
---|---|
LoginException |
LogoutAsync()
Logout current user and switch to a guest user
Declaration
public async Task LogoutAsync()
Returns
Type | Description |
---|---|
Task |
Exceptions
Type | Condition |
---|---|
LogoutException |
SetLicense(String)
Sets this game's license for logging purpose.
Declaration
public void SetLicense(string license)
Parameters
Type | Name | Description |
---|---|---|
System.String | license |
SetSession(String)
Sets current session id for logging purpose.
Declaration
public void SetSession(string session)
Parameters
Type | Name | Description |
---|---|---|
System.String | session |
SetUserType(UserType)
Sets user type which represent what application is user using
Declaration
public void SetUserType(UserType userType)
Parameters
Type | Name | Description |
---|---|---|
UserType | userType |