39 lines
1.1 KiB
HTML
39 lines
1.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
<title>Hello</title>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
</body>
|
|
<script>
|
|
// We can get the token from the "access_token" query
|
|
// param, available in the browsers "location" global
|
|
const query = window.location.search.substring(1)
|
|
const token = query.split('access_token=')[1]
|
|
console.log("FFFFFFFFFFFFFFFFFFFFFFFFf")
|
|
// Call the user info API using the fetch browser library
|
|
fetch('https://api.github.com/user', {
|
|
headers: {
|
|
Accept: "application/vnd.github.v3+json",
|
|
// Include the token in the Authorization header
|
|
Authorization: 'token ' + token
|
|
}
|
|
})
|
|
// Parse the response as JSON
|
|
.then(res => res.json())
|
|
.then(res => {
|
|
// Once we get the response (which has many fields)
|
|
// Documented here: https://developer.github.com/v3/users/#get-the-authenticated-user
|
|
// Write "Welcome <user name>" to the documents body
|
|
const nameNode = document.createTextNode(`Welcome, ${res.name}`)
|
|
document.body.appendChild(nameNode)
|
|
})
|
|
</script>
|
|
|
|
</html> |