-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for auto grabbing auth code
Allow assistant to pick-up OAuth authorization code automatically from post consent screen if redirect URI points to localhost (port 5754) - Add dep: express.js - Add page for successful authorization - Update link for dep `google-assistant` with prefix `github:` Addresses Authentication Failure #671
- Loading branch information
1 parent
1bb0acb
commit 32be4ab
Showing
8 changed files
with
19,622 additions
and
10,841 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const path = require('path'); | ||
const express = require('express'); | ||
|
||
const app = express(); | ||
const port = 5754; | ||
const authHandleRedirectUri = '/auth/handler'; | ||
const authSuccessPath = '/auth/success'; | ||
|
||
const authSuccessPageServePath = path.join(__dirname, 'authSuccess'); | ||
const authSuccessPageStaticServeRequestHandler = express.static(authSuccessPageServePath); | ||
|
||
app.use(authSuccessPath, authSuccessPageStaticServeRequestHandler); | ||
|
||
app.get(authHandleRedirectUri, (req, res) => { | ||
const { query } = req; | ||
const authCode = query.code; | ||
|
||
const getTokenView = document.querySelector('[name=get-token]'); | ||
|
||
// If "Get Token" screen is currently not the active view | ||
// No need to do anything | ||
if (getTokenView === null) { | ||
res.send('Invalid auth session. "Get Token" screen is not active...'); | ||
return; | ||
} | ||
|
||
// If auth code is not a part of URL query, do nothing | ||
if (authCode === undefined) { | ||
res.send('No auth code provided for authorization'); | ||
return; | ||
} | ||
|
||
/** @type {HTMLInputElement} */ | ||
const authCodeInputField = getTokenView.querySelector('#auth-code-input'); | ||
authCodeInputField.value = authCode; | ||
|
||
const suggestionArea = document.querySelector('#suggestion-area'); | ||
|
||
/** @type {HTMLButtonElement} */ | ||
const submitAuthCodeButton = suggestionArea.querySelector('#submit-btn'); | ||
submitAuthCodeButton.click(); | ||
|
||
// Let the user know that the auth was successful | ||
res.redirect(authSuccessPath); | ||
}); | ||
|
||
app.listen(port, () => { | ||
console.log(`Auth handler listener started in port: ${port}`); | ||
}); |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="./style.css"> | ||
<title>Authorization Successful | Google Assistant Unofficial Desktop Client</title> | ||
</head> | ||
<body> | ||
<main> | ||
<img src="./auth.svg" alt=""> | ||
|
||
<div> | ||
<h1> | ||
You have been successfully authorized | ||
</h1> | ||
|
||
<div> | ||
The authorization code has been picked up by the client. | ||
Your access tokens will be fetched shortly. | ||
You may now close this window. | ||
</div> | ||
</div> | ||
</main> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;700&display=swap'); | ||
|
||
html { | ||
background-color: #121212; | ||
color: #ffffff; | ||
font-family: 'Plus Jakarta Sans', sans-serif; | ||
font-size: 16px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100vh; | ||
width: 100vw; | ||
} | ||
|
||
html::before { | ||
content: ''; | ||
height: 100%; | ||
width: 100%; | ||
position: fixed; | ||
background-image: url(./cloud_confetti.png); | ||
background-repeat: no-repeat; | ||
background-position: bottom left; | ||
background-size: 25rem; | ||
} | ||
|
||
html::after { | ||
content: ''; | ||
height: 100%; | ||
width: 100%; | ||
position: fixed; | ||
top: 0; | ||
right: 0; | ||
background-image: url(./cloud_confetti.png); | ||
background-repeat: no-repeat; | ||
background-position: bottom left; | ||
background-size: 25rem; | ||
transform: rotate(180deg); | ||
} | ||
|
||
main { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 2rem; | ||
width: 55ch; | ||
text-align: center; | ||
} |
Oops, something went wrong.