initial commit
This commit is contained in:
17
public/index.html
Normal file
17
public/index.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>Node oAuth2 Example</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- <link rel="stylesheet" type="text/css" media="screen" href="main.css" /> -->
|
||||
<!-- <script src="main.js"></script> -->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="http://localhost:8180/realms/master/protocol/openid-connect/auth?client_id=karkarcar&redirect_uri=http://localhost:8080/oauth/redirect&response_type=code&scope=openid">Login with keycloak</a>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
39
public/welcome.html
Normal file
39
public/welcome.html
Normal file
@@ -0,0 +1,39 @@
|
||||
<!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>
|
||||
Reference in New Issue
Block a user