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; AuthorizationToken? AuthToken; User? UserInfo; bool HasActiveLicense; UnityEvent LoggedIn; UnityEvent LoggedOut; UnityEvent LicenseGranted; UnityEvent LicenseRevoked; License.? LicenseType CachedLicenseType; // 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 Status, User? User)> GetUser(bool forceFetchFromServer = false); async Task<(ResponseStatusCode Status, License? 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 Status, User? User)> GetUser(bool forceFetchFromServer = false);
Task<(ResponseStatusCode Status, License? License)> GetActiveLicense(bool forceFetchFromServer = false);
Task SendRequestAsync(
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.
AuthorizationToken? AuthToken
Gets the developer’s current authorization token, if any. Exposed so that runtime auth modules can borrow the editor session in Play mode (where the player-side MagesClientCredentialsConfig hasn’t been baked, since the baker only runs on build). Null when not logged in or when running outside the editor.
User? UserInfo
Gets the developer’s cached user record (id, email, tenant). Populated lazily by GetUser(bool); exposed so the editor bridge can hand the runtime auth module a usable User in Play mode without each module having to call /api/users/current itself.
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.
License.? LicenseType CachedLicenseType
Gets the developer’s currently cached license type, or null if no license has been resolved yet.
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 Status, User? 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 Status, License? 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.