Created
May 4, 2017 18:17
-
-
Save Razzwan/6850da93d7cb4a6bca0fcae5c5bbdc46 to your computer and use it in GitHub Desktop.
OAuth registration/login
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script> | |
/* | |
The data is accessible in two ways: | |
1. Using the postMessage api, this window will respond to a | |
'message' event with a post of all the data. (This can | |
be used by browsers other than IE if this window was | |
opened with window.open()) | |
2. This window has a function called requestCredentials which, | |
when called, will return the data. (This can be | |
used if this window was opened in an inAppBrowser using | |
Cordova / PhoneGap) | |
*/ | |
var data = <?= $data ?>; | |
window.addEventListener("message", function(ev) { | |
if (ev.data === "requestCredentials") { | |
ev.source.postMessage(data, '*'); | |
window.close(); | |
} | |
}); | |
setTimeout(function() { | |
document.getElementById('text').innerHTML = (data && data.error) || 'Redirecting...'; | |
}, 1000); | |
// for android App | |
function androidAppReceive() { | |
if (window.AndroidApp) { | |
window.AndroidApp.requestCredentials(JSON.stringify(data)); | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<pre id="text"> | |
</pre> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment