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
auth.on("closed", () => { | |
setIsLoggingIn(false); | |
}); | |
auth.on("authenticated", result => { | |
setIsLoggedIn(true); | |
updateUserTokens(); | |
}); | |
auth.on("logged_out", () => { |
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
return ( | |
<div className="wrapper"> | |
<h1>Application</h1> | |
<button onClick={() => { | |
if (isLoggingIn) { | |
handleCancelLogin(); | |
return; | |
} | |
if (isLoggedIn) { | |
handleLogout(); |
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
const express = require('express'); | |
const cors = require('cors'); | |
const app = express(); | |
const jwt = require('jsonwebtoken'); | |
const jwksClient = require('jwks-rsa'); | |
const VALID_CLIENT_ID = 'YOUR CLIENT ID'; |
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
app.use(cors()); | |
app.use('/adminInfo', async (req, res) => { | |
// Code Here | |
}); | |
app.listen(8080, () => console.log('API is running on http://localhost:8080/adminInfo')); |
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
const token = authHeader && authHeader.split(' ')[1]; | |
if (token == null) return res.sendStatus(401); | |
// Verify JWT Token Signature | |
let decodedToken = jwt.decode(token, { complete: true }); | |
let kid = decodedToken.header.kid; | |
let clientId = decodedToken.payload.client_id; | |
// Checks if client id is expected id | |
if (clientId !== VALID_CLIENT_ID) { |
OlderNewer