Created
March 12, 2018 06:50
-
-
Save clayrisser/b218c18249d8c0324fca2919cff2a119 to your computer and use it in GitHub Desktop.
Social Login Example
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 lang="en"> | |
<head> | |
<meta charset="UTF-8"/> | |
<title>Document</title> | |
</head> | |
<body> | |
<a onclick="loginGithub()" href="#">Login w/ GitHub</a> | |
</body> | |
<script> | |
function loginGithub() { | |
var githubPage = window.open('http://localhost:6600/api/v1/auth/provider/github'); | |
function githubPageClosed() { | |
if (githubPage.closed) { | |
var data = null; | |
var xhr = new XMLHttpRequest(); | |
xhr.withCredentials = true; | |
xhr.addEventListener("readystatechange", function () { | |
if (this.readyState === 4) { | |
console.log(this.responseText); | |
} | |
}); | |
xhr.open("GET", "http://localhost:6600/api/v1/auth/authed"); | |
xhr.setRequestHeader("Cache-Control", "no-cache"); | |
xhr.setRequestHeader("Postman-Token", "16c4e463-e2c8-3816-2c6a-5daf55ac2a1a"); | |
xhr.send(data); | |
clearInterval(timer); | |
} | |
} | |
var timer = setInterval(githubPageClosed, 500); | |
} | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment