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