LaunchKey SDK for .NET

Use this SDK to interact with the LaunchKey API in your .NET service.

Obtain the SDK


To use the LaunchKey NuGet, run the following command in the Package Manager Console:

PM> Install-Package LaunchKey.SDK

Download Source

LaunchKey .NET SDK

Clone Source

Before You Begin

Before you can begin using the LaunchKey API, you need a service. If you have not created a service yet, you can use our Getting Started Guide to create one.

Create A LaunchKey API Object

To begin using the library, you must first create an instance of launchKeyRestClient supplied with your Service key, secret key and private key available from the app details page of your LaunchKey subscriber Service.


LaunchKeyRestClient(appKey, appSecretKey, appPrivateRsaKey)


appKey:integer Unique 10-digit Service key from your Service details tab in dashboard
appSecretKey:string Service secret key from your Service's keys tab in dashboard
appPrivateRsaKey:string Service RSA private key from your Service's keys tab in dashboard

Example Code

/* Create an instance of LaunchKeyRestClient */
var appKey = "123457890";
var appSecretKey = "my_secret_key";
var appPrivateRsaKey = File.ReadAllText("path/to/private_key.rsa");

var client = new LaunchKeyRestClient(

Authenticating A User

To authenticate a user, use the Authenticate() method with the user's LaunchKey username. Optionally, set AuthenticationType.Session = False for a transactional authentication request (see explanation below). If the request is successfully sent, the JSON response will include the auth_request code which you'll use to reference this auth request in subsequent calls.


LaunchKey.SDK.Rest.AuthsResponse LaunchKeyRestClient.Authenticate(username, authType, userPushId)


username:string LaunchKey username, user push ID, or end-user identifier for the user
authType:LaunchKey.SDK.Rest.AuthenticationType Enum value of Session or Transaction. See Sessions vs. Transactions for usage.
userPushId:bool true to return unique user id for initiating authentication.


LaunchKey.SDK.Rest.AuthsResponse object with the following properties:

AuthRequest:string LaunchKey auth request ID

Sessions vs. Transactions

Auth requests (authentication requests) can be designated as sessions or transactions based on the needs of your service. Sessions should be used when the user will have the ability to end an active session and log out (e.g. signing in and out of a website or app), whereas transactions are inactive one-way authorizations where the situation doesn't merit the need for remote logout (e.g. approving receipt of a package). Within the LaunchKey app, the end user will see a blue dot next to active sessions and a grey dot next to inactive transactions. Sessions are default.

Example Request

var authResponse = client.Authenticate("launchkey_username", AuthenticationType.Session, false);
if (!authResponse.Successful)
    // Auth request failed for some reason, check authResponse.MessageCode, bail

Determine Status of Auth Request

Once you've sent an auth request to a user, you'll need to check the status of that request periodically to determine whether or not the user has responded. Do this with the Poll() method. Auth requests remain valid for 5 minutes.


LaunchKey.SDK.Rest.PollResponse LaunchKeyRestClient.Poll(authRequest)


authRequest:string The request-specific code


LaunchKey.SDK.Rest.PollResponse object with the following properties:


string Encrypted and Base64 encoded authentication package delivered from the API


LaunchKey.SDK.Rest.DecryptedPollResponse object with the following properties:

Response:bool Authentication outcome. true for success, false for failure
AuthRequest:string Unique ID associated with the auth request

string Unique user hash. Represents a permanently unique identifier to identify a user within a LaunchKey Service.

Example Code

PollResponse pollResponse;
    pollResponse = client.Poll(authResponse.AuthRequest);
} while (pollResponse.MessageCode == LaunchKeyResponseCode.PollErrorResponsePending);

Decrypt & Check Response

When the user responds, use the IsAuthorized() method to determine the user's response.


bool LaunchKeyRestClient.IsAuthorized(authRequest, response)


authRequest:string The request-specific code
pollResponse:LaunchKey.SDK.Rest.PollResponse The response to validate


bool value. If true, you should continue authenticating the user in your service or consider them logged in. The PollResponse object will include a property UserHash which you can use to uniquely identify that LaunchKey user within your service. If false, the PollResponse.MessageCode property will indicate why the request failed.

Example Code

bool success = client.IsAuthorized(pollResponse);

When A User Logs Out

If a user logs out from within your service, you should inform our API so we can take your Service out of the user's authorization list.


bool LaunchKeyRestClient.Logout(authRequest)


authRequest:string The request-specific code


bool value representing the success of the request.

Example Code

bool success = client.Logout(pollResponse);

When A User Remotely Logs Out

A user can remotely log out from an active session within the Mobile Authenticator App, as opposed to logging out directly within your service. When your service receives notification from the LaunchKey Engine that a user has remotely logged out, call the clear() method to verify the logout.

Once verified, the User Hash will be returned. Use this hash to determine which user within your system you need to log out. Once you've logged out the user, inform the LaunchKey Engine that the user has been successfully logged out by calling the Logout() method.


string LaunchKeyRestClient.clear(orbitData, signature)


orbitData:string Remote logout request package
signature:string Used to validate that a remote logout request came from LaunchKey


string value representing the success of the request.

Example Code

string userHash = client.clear(orbitData, signature);
if (userHash != null)
    // Perform user logout in service and retrieve authRequest

User Contributed

LaunchKey links to user contributed code as a resource to its community. LaunchKey does not in any way guarantee or warrant the quality and security of these code bases. User contributed code is supported by the creators. If you do find a link from the site to user contributed code that is malicious or inappropriate in any way, please report that link to LaunchKey immediately and we will investigate the claim. Submit any issue to LaunchKey support at ×