Last active
December 19, 2015 10:29
-
-
Save cgmartin/5941288 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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