Skip to content

Instantly share code, notes, and snippets.

View lkdocs's full-sized avatar

LaunchKey Documentation Examples lkdocs

View GitHub Profile
@lkdocs
lkdocs / LaunchKey Node.js SDK - AuthRequest Object.js
Created March 30, 2015 22:30
LaunchKey Node.js SDK - AuthRequest Object
var AuthRequest = require("launchkey-sdk").AuthRequest,
authRequest = new AuthRequest("auth request ID");
launchKey.deOrbit(authRequest);
@lkdocs
lkdocs / LaunchKey Node.js SDK - Authorize Transaction.js
Created March 30, 2015 22:19
LaunchKey Node.js SDK - Authorize Transaction
launchKey.authorize(
"LaunchKeyUserName",
function (authRequest) {
console.log("Authorization request successful", authRequest);
},
function (error) {
console.error("Error processsing authorization request!", error);
}
);
@lkdocs
lkdocs / LaunchKey Node.js SDK - Authenticate User.js
Last active August 29, 2015 14:18
LaunchKey Node.js SDK - Authenticate User
launchKey.authenticate(
"LaunchKeyUserName",
function (authRequest) {
console.log("Authentication request successful", authRequest);
},
function (error) {
console.error("Error processsing authentication request!", error);
}
);
@lkdocs
lkdocs / LaunchKey Node.js SDK - Instantiate Client.js
Last active August 29, 2015 14:18
LaunchKey Node.js SDK - Instantiate Client
var LaunchKey = require("launchkey-sdk"),
appKey = "1234567890",
secretKey = "qwertyuiodfghjklcvbnm",
privateKey = "-----BEGIN RSA PRIVATE KEY-----...-----END RSA PRIVATE KEY-----",
launchKey;
launchKey = new LaunchKey(appKey, secretKey, privateKey);
var logoutResult = await LKOAuthManager.Instance.logout(accessToken) as LaunchKeyLogoutResponse;
public class LaunchKeyLogoutResponse
{
public bool Successful { get; set; }
public bool LoggedOut { get; set; }
public string ErrorMessage { get; set; }
public string ErrorCode { get; set; }
}
var authorizationResult = await LKOAuthManager.Instance.isAuthorized(accessToken) as LaunchKeyIsAuthorizedResponse;
public class LaunchKeyIsAuthorizedResponse
{
public bool Successful { get; set; }
public bool Authorized { get; set; }
public string ErrorMessage { get; set; }
public string ErrorCode { get; set; }
}
public void loginSuccessCallback(string userId, string accessToken)
{
// success
}
public void loginFailureCallback(string errorMessage, string errorCode)
{
// failure
}
LKOAuthManager.Instance.promptForLaunchKeyLogin(loginSuccessCallback, loginFailureCallback);
using LaunchKeyManager;
LKOAuthManager.Instance.init(appKey, redirectUri);
IsLoggedOutResponse response = await LKAuthenticationManager.Instance.logout(_authRequest) as IsLoggedOutResponse;
if (response.LoggedOut)
{
//logged out
}