From: Ardis Lu Date: Sun, 29 Jan 2023 04:25:44 +0000 (-0800) Subject: Move OAuth scopes into the function X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=bf2089053b16b3cba926023c1c81aef7567b560b;p=ardislu.dev Move OAuth scopes into the function This is not sensitive info so doesn't need to be an env variable --- 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}` } }); }