From bf2089053b16b3cba926023c1c81aef7567b560b Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Sat, 28 Jan 2023 20:25:44 -0800 Subject: [PATCH] Move OAuth scopes into the function This is not sensitive info so doesn't need to be an env variable --- .dev.vars.example | 1 - functions/api.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.dev.vars.example b/.dev.vars.example index 63dc5c2..519e078 100644 --- a/.dev.vars.example +++ b/.dev.vars.example @@ -1,3 +1,2 @@ EMAIL="example@example.com" PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...EXAMPLE...\n-----END PRIVATE KEY-----\n" -SCOPES="https://www.googleapis.com/auth/spreadsheets.readonly https://www.googleapis.com/auth/documents.readonly" diff --git a/functions/api.js b/functions/api.js index 15e5857..572a116 100644 --- a/functions/api.js +++ b/functions/api.js @@ -9,7 +9,7 @@ export async function onRequestGet({ request, env }) { return new Response('Invalid query URL. Query URL hostname must be "sheets.googleapis.com" or "docs.googleapis.com".', { status: 400 }); } - const token = await getGoogleAuthToken(env.EMAIL, env.PRIVATE_KEY, env.SCOPES); + const token = await getGoogleAuthToken(env.EMAIL, env.PRIVATE_KEY, 'https://www.googleapis.com/auth/spreadsheets.readonly https://www.googleapis.com/auth/documents.readonly'); return fetch(queryUrl, { headers: { Authorization: `Bearer ${token}` } }); } -- 2.47.3