From aae9287bbe2fc35c302ed61ef520e5fa09fc5b4d Mon Sep 17 00:00:00 2001 From: Anna Romanova Date: Thu, 27 Feb 2025 08:45:17 -0800 Subject: [PATCH 1/3] fix: issue with refreshing token when client_secret is not set (#513) * Fix issue with refreshing token when client_secret is not set * check that refreshed token has refreshTokenExpiresAt set --- dist/OAuth2.gs | 1 - src/Service.js | 1 - test/test.js | 29 +++++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/dist/OAuth2.gs b/dist/OAuth2.gs index adf3bb84..ce97757c 100644 --- a/dist/OAuth2.gs +++ b/dist/OAuth2.gs @@ -759,7 +759,6 @@ Service_.prototype.ensureExpiresAtSet_ = function(token) { Service_.prototype.refresh = function() { validate_({ 'Client ID': this.clientId_, - 'Client Secret': this.clientSecret_, 'Token URL': this.tokenUrl_ }); diff --git a/src/Service.js b/src/Service.js index 68bd3e7f..e7527fe1 100644 --- a/src/Service.js +++ b/src/Service.js @@ -666,7 +666,6 @@ Service_.prototype.ensureExpiresAtSet_ = function(token) { Service_.prototype.refresh = function() { validate_({ 'Client ID': this.clientId_, - 'Client Secret': this.clientSecret_, 'Token URL': this.tokenUrl_ }); diff --git a/test/test.js b/test/test.js index 1e8317f7..fe7aca71 100644 --- a/test/test.js +++ b/test/test.js @@ -387,6 +387,35 @@ describe('Service', () => { done(); }); + it('should refresh token granted for PKCE', () => { + const NOW_SECONDS = OAuth2.getTimeInSeconds_(new Date()); + const ONE_HOUR_AGO_SECONDS = NOW_SECONDS - 360; + var token = { + granted_time: ONE_HOUR_AGO_SECONDS, + expires_in: 100, + refresh_token: 'bar', + refresh_token_expires_in: 720 + }; + var properties = new MockProperties({ + 'oauth2.test': JSON.stringify(token) + }); + + mocks.UrlFetchApp.resultFunction = () => JSON.stringify({ + access_token: Math.random().toString(36) + }); + + OAuth2.createService('test') + .setClientId('test') + .setTokenUrl('http://www.example.com/') + .setPropertyStore(properties) + .generateCodeVerifier() + .refresh(); + + var storedToken = JSON.parse(properties.getProperty('oauth2.test')); + assert.equal(storedToken.refresh_token, 'bar'); + assert.equal(storedToken.refreshTokenExpiresAt, NOW_SECONDS + 360); + }); + it('should retain refresh expiry', () => { const NOW_SECONDS = OAuth2.getTimeInSeconds_(new Date()); const ONE_HOUR_AGO_SECONDS = NOW_SECONDS - 360; From 4b24e0311488a54c82513da88162d7cde690536f Mon Sep 17 00:00:00 2001 From: googleworkspace-bot <109114539+googleworkspace-bot@users.noreply.github.com> Date: Tue, 18 Nov 2025 15:43:05 -0700 Subject: [PATCH 2/3] chore: Created local '.gemini/' from remote 'sync-files/defaults/.gemini/' (#545) --- .gemini/GEMINI.md | 12 ++++++++++++ .gemini/config.yaml | 12 ++++++++++++ .gemini/settings.json | 8 ++++++++ 3 files changed, 32 insertions(+) create mode 100644 .gemini/GEMINI.md create mode 100644 .gemini/config.yaml create mode 100644 .gemini/settings.json diff --git a/.gemini/GEMINI.md b/.gemini/GEMINI.md new file mode 100644 index 00000000..0f175c59 --- /dev/null +++ b/.gemini/GEMINI.md @@ -0,0 +1,12 @@ +# Overview + +This codebase is part of the Google Workspace GitHub organization, https://github.com/googleworkspace. + +## Style Guide + +Use open source best practices for code style and formatting with a preference for Google's style guides. + +## Tools + +- Verify against Google Workspace documentation with the `workspace-developer` MCP server tools. +- Use `gh` for GitHub interactions. diff --git a/.gemini/config.yaml b/.gemini/config.yaml new file mode 100644 index 00000000..a4814a5f --- /dev/null +++ b/.gemini/config.yaml @@ -0,0 +1,12 @@ +# Config for the Gemini Pull Request Review Bot. +# https://github.com/marketplace/gemini-code-assist +have_fun: false +code_review: + disable: false + comment_severity_threshold: "HIGH" + max_review_comments: -1 + pull_request_opened: + help: false + summary: true + code_review: true +ignore_patterns: [] diff --git a/.gemini/settings.json b/.gemini/settings.json new file mode 100644 index 00000000..ec3565d5 --- /dev/null +++ b/.gemini/settings.json @@ -0,0 +1,8 @@ +{ + "mcpServers": { + "workspace-developer": { + "httpUrl": "https://workspace-developer.goog/mcp", + "trust": true + } + } +} \ No newline at end of file From 12b6d6b30a7c80e72ecb736f1318941323574a4c Mon Sep 17 00:00:00 2001 From: googleworkspace-bot <109114539+googleworkspace-bot@users.noreply.github.com> Date: Tue, 18 Nov 2025 15:47:20 -0700 Subject: [PATCH 3/3] chore: Synced file(s) with googleworkspace/.github --- .vscode/extensions.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .vscode/extensions.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..4a9deaa4 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "google-workspace.google-workspace-developer-tools" + ] +} \ No newline at end of file