Skip to content

Instantly share code, notes, and snippets.

@cgmartin
Last active December 19, 2015 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cgmartin/5941288 to your computer and use it in GitHub Desktop.
Save cgmartin/5941288 to your computer and use it in GitHub Desktop.
var sess;
ab.connect(
// ...
function (session) { // Connection callback
// Authenticate
var username = 'guest';
var password = 'secret-password';
// send authreq rpc call
sess.authreq(username).then(
function (challenge) {
console.log("Received auth challenge", challenge);
var signature = sess.authsign(password, challenge);
// send auth rpc call
sess.auth(signature).then(
function(permissions) {
console.log("Authentication complete", permissions);
// ... carry on with our connection setup,
// ... adding subscriptions, etc.
},
function() { console.log("Authentication failed"); });
},
function() { console.log("AuthRequest failed"); });
},
// ...
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment