Skip to content

Instantly share code, notes, and snippets.

@tejovanthn
Last active September 13, 2015 14:37
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 tejovanthn/1bd3d84699f741b7bb36 to your computer and use it in GitHub Desktop.
Save tejovanthn/1bd3d84699f741b7bb36 to your computer and use it in GitHub Desktop.
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