class MAGES::Editor::DeveloperAuthentication

Overview

Handles authentication for MAGES. More…

class DeveloperAuthentication
{
public:
    // structs

    struct AuthorizationToken;
    struct CheckoutLicenseRequestBody;
    struct HeartbeatLicenseRequestBody;

    // properties

    UnityEvent LoggedIn;
    UnityEvent LoggedOut;
    UnityEvent LicenseGranted;
    UnityEvent LicenseRevoked;
    bool IsLoggedIn;
    bool HasValidSDKLicense;

    // methods

    static void Login(
        string username,
        string password,
        Action<RequestResult> onRequestCompleted
    );

    static void Logout();

    static void GetUserInfo(
        Action<RequestResult, User?> onRequestCompleted,
        bool onlineMode = false
    );

    static void GetLicenseInfo(
        Action<RequestResult, LicenseInfo?> onRequestCompleted,
        bool onlineMode = false
    );

    static void GetLicenseLimits(
        Action<RequestResult, LicenseLimits?> onRequestCompleted,
        bool onlineMode = false
    );

    static async Task<(RequestResult Result, LicenseLimits? Limits)> GetLicenseLimitsAsTask(bool onlineMode = false);

    static async Task SendRequestAsync(
        HttpRequestMessage msg,
        HttpCompletionOption completionOption,
        CancellationToken cancellationToken
    );

    static async Task SendRequestAsync(HttpRequestMessage msg);

    static async Task SendRequestAsync(
        HttpRequestMessage msg,
        HttpCompletionOption completionOption
    );

    static async Task SendRequestAsync(
        HttpRequestMessage msg,
        CancellationToken cancellationToken
    );
};

Detailed Documentation

Handles authentication for MAGES.

Properties

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.

bool IsLoggedIn

Gets a value indicating whether a developer is logged in.

bool HasValidSDKLicense

Gets a value indicating whether the developer has a valid SDK license.

Methods

static void Login(
    string username,
    string password,
    Action<RequestResult> onRequestCompleted
)

Logins to the MAGES server.

Parameters:

username

Username.

password

Password.

onRequestCompleted

Action to be invoked when the login request is completed.

static void Logout()

Log out from the MAGES server.

static void GetUserInfo(
    Action<RequestResult, User?> onRequestCompleted,
    bool onlineMode = false
)

Gets the User Info.

Parameters:

onRequestCompleted

The action to be invoked when the request has finished.

onlineMode

If set to true it will force to refetch user info from the server. Otherwise, if cached info is available will use that.

static void GetLicenseInfo(
    Action<RequestResult, LicenseInfo?> onRequestCompleted,
    bool onlineMode = false
)

Gets the checked out license info. If no license is checked out it will check out a license.

Parameters:

onRequestCompleted

onRequestCompleted arg1

The result of the request.

onRequestCompleted arg2

onlineMode

If set to true it will force to refetch license info from the server. Otherwise, if cached info is available will use that.

static void GetLicenseLimits(
    Action<RequestResult, LicenseLimits?> onRequestCompleted,
    bool onlineMode = false
)

Gets the license limits based on the license type.

Parameters:

onRequestCompleted

The action to be invoked when the request has completed.

onlineMode

Whether to fetch the latest information from the online server or use locally cached results if available.

static async Task<(RequestResult Result, LicenseLimits? Limits)> GetLicenseLimitsAsTask(bool onlineMode = false)

Gets the license data as an asynchronous task.

Parameters:

onlineMode

Force get limits from online server.

Returns:

The async task.

static async Task SendRequestAsync(
    HttpRequestMessage msg,
    HttpCompletionOption completionOption,
    CancellationToken cancellationToken
)

Adds the Authorization header and sends the web 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.

static async Task SendRequestAsync(HttpRequestMessage msg)

Adds the Authorization header and sends the web request.

Parameters:

msg

The HTTP request message to send.

Returns:

The task object representing the asynchronous operation.

static async Task SendRequestAsync(
    HttpRequestMessage msg,
    HttpCompletionOption completionOption
)

Adds the Authorization header and sends the web 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.

static async Task SendRequestAsync(
    HttpRequestMessage msg,
    CancellationToken cancellationToken
)

Adds the Authorization header and sends the web request.

Parameters:

msg

The HTTP request message to send.

cancellationToken

The cancellation token to cancel operation.

Returns:

The task object representing the asynchronous operation.