class MAGES::Editor::DeveloperAuthentication¶
Overview¶
A singleton responsible for Authenticating Developers. More…
class DeveloperAuthentication: public MAGES::IAuthenticationAPI { public: // structs struct CheckoutLicenseRequestBody; struct HeartbeatLicenseRequestBody; // properties DeveloperAuthentication Instance; bool IsLoggedIn; bool HasActiveLicense; UnityEvent LoggedIn; UnityEvent LoggedOut; UnityEvent LicenseGranted; UnityEvent LicenseRevoked; // methods async Task<ResponseStatusCode> LogIn(string username, string password); void LogOut(); async Task<ResponseStatusCode> LogInAndRequestLicense( string username, string password ); async Task<ResponseStatusCode> RequestLicense(); async Task<(ResponseStatusCode, User?)> GetUser(bool forceFetchFromServer = false); async Task<(ResponseStatusCode, License?)> GetActiveLicense(bool forceFetchFromServer = false); async Task<(ResponseStatusCode, LicenseLimits?)> GetLicenseLimits(bool forceFetchFromServer = false); async TaskSendRequestAsync( HttpRequestMessage msg, HttpCompletionOption completionOption, CancellationToken cancellationToken ); async Task SendRequestAsync(HttpRequestMessage msg); async Task SendRequestAsync( HttpRequestMessage msg, HttpCompletionOption completionOption ); async Task SendRequestAsync( HttpRequestMessage msg, CancellationToken cancellationToken ); };
Inherited Members¶
public: // properties UnityEvent LoggedIn; UnityEvent LoggedOut; UnityEvent LicenseGranted; UnityEvent LicenseRevoked; bool IsLoggedIn; bool HasActiveLicense; // methods Task<ResponseStatusCode> LogIn(string username, string password); void LogOut(); Task<ResponseStatusCode> LogInAndRequestLicense( string username, string password ); Task<ResponseStatusCode> RequestLicense(); Task<(ResponseStatusCode, User?)> GetUser(bool forceFetchFromServer = false); Task<(ResponseStatusCode, License?)> GetActiveLicense(bool forceFetchFromServer = false); TaskSendRequestAsync( HttpRequestMessage msg, HttpCompletionOption completionOption, CancellationToken cancellationToken ); Task SendRequestAsync(HttpRequestMessage msg); Task SendRequestAsync( HttpRequestMessage msg, HttpCompletionOption completionOption ); Task SendRequestAsync( HttpRequestMessage msg, CancellationToken cancellationToken );
Detailed Documentation¶
A singleton responsible for Authenticating Developers.
Properties¶
DeveloperAuthentication Instance
Gets the DeveloperAuthentication Singleton.
bool IsLoggedIn
Gets a value indicating whether a user is logged in.
bool HasActiveLicense
Gets a value indicating whether the user has activated a license.
UnityEvent LoggedIn
Gets or sets the event invoked immediately after a developer has logged in.
UnityEvent LoggedOut
Gets or sets the event invoked immediately after the developer gets logged out.
UnityEvent LicenseGranted
Gets or sets the event invoked immediately after the developer’s license is granted.
UnityEvent LicenseRevoked
Gets or sets the event invoked immediately after the developer’s license gets invalidated.
Methods¶
async Task<ResponseStatusCode> LogIn(string username, string password)
Perform Login.
Parameters:
username |
The username. |
password |
The password. |
Returns:
The request status code.
void LogOut()
Performs log out.
async Task<ResponseStatusCode> LogInAndRequestLicense( string username, string password )
Logs in and requests a license.
Parameters:
username |
The username. |
password |
The password. |
Returns:
The request status code.
async Task<ResponseStatusCode> RequestLicense()
Requests a license.
Returns:
The request status code.
async Task<(ResponseStatusCode, User?)> GetUser(bool forceFetchFromServer = false)
Gets the User Information.
Parameters:
forceFetchFromServer |
If set to |
Returns:
The request status code and the logged in User, if any.
async Task<(ResponseStatusCode, License?)> GetActiveLicense(bool forceFetchFromServer = false)
Gets the currently active license, or a new one if no active license is found.
Parameters:
forceFetchFromServer |
If set to |
Returns:
The request status code and the currently active license, if any.
async Task<(ResponseStatusCode, LicenseLimits?)> GetLicenseLimits(bool forceFetchFromServer = false)
Gets the limits for this license.
Parameters:
forceFetchFromServer |
If set to |
Returns:
The request status code and the currently active license’s limits, if any.
async TaskSendRequestAsync( HttpRequestMessage msg, HttpCompletionOption completionOption, CancellationToken cancellationToken )
Adds the Authorization header and sends the web request. If the request fails due to an expired access token, it will try to refresh the token and retry the request.
Parameters:
msg |
The HTTP request message to send. |
completionOption |
When the operation should complete (as soon as a response is available or after reading the whole response content). |
cancellationToken |
The cancellation token to cancel operation. |
Returns:
The task object representing the asynchronous operation.
async TaskSendRequestAsync(HttpRequestMessage msg)
Adds the Authorization header and sends the web request. If the request fails due to an expired access token, it will try to refresh the token and retry the request.
Parameters:
msg |
The HTTP request message to send. |
Returns:
The task object representing the asynchronous operation.
async TaskSendRequestAsync( HttpRequestMessage msg, HttpCompletionOption completionOption )
Adds the Authorization header and sends the web request. If the request fails due to an expired access token, it will try to refresh the token and retry the request.
Parameters:
msg |
The HTTP request message to send. |
completionOption |
When the operation should complete (as soon as a response is available or after reading the whole response content). |
Returns:
The task object representing the asynchronous operation.
async TaskSendRequestAsync( HttpRequestMessage msg, CancellationToken cancellationToken )
Adds the Authorization header and sends the web request. If the request fails due to an expired access token, it will try to refresh the token and retry the request.
Parameters:
msg |
The HTTP request message to send. |
cancellationToken |
The cancellation token to cancel operation. |
Returns:
The task object representing the asynchronous operation.