Skip to content

Instantly share code, notes, and snippets.

@tejovanthn tejovanthn/digits.js
Last active Sep 13, 2015

Embed
What would you like to do?
Digits integration
//Include <script id="digits-sdk" src="https://cdn.digits.com/1/sdk.js" async></script> in <head></head>
document.getElementById('digits-sdk').onload = function() {
Digits.init({ consumerKey: 'NpImh5k6yWhDAyhiafRop44Ur' })
.done(function(){
console.log("Digits is initialized")
})
.fail(function(){
console.log("Digits failed to initialize")
})
console.log('sdk ready');
};
$(document).ready(function(){
function onLogin(loginResponse){
var oAuthHeaders = loginResponse.oauth_echo_headers;
var verifyData = {
authHeader: oAuthHeaders['X-Verify-Credentials-Authorization'],
apiUrl: oAuthHeaders['X-Auth-Service-Provider']
};
$.post('/verify', verifyData)
.done(function(){ console.log("Login Done"); window.location.reload(); })
.fail(function(){ console.log("Login Fail");})
.always(function() { console.log("Login always");});
}
function onLoginFailure(error){
console.log('Login Failure: ', error);
}
function onLoginButtonClick(event){
Digits.logIn()
.done(onLogin) /*handle the response*/
.fail(onLoginFailure);
}
document.getElementById("login-button").onclick = onLoginButtonClick;
document.getElementById("login-continue").onclick = onLoginButtonClick;
document.getElementById("login-confused").onclick = onLoginButtonClick;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.