Skip to content

Commit d0bb05b

Browse files
committed
update axios, fix new google-auth-library issue, fixes #701 #700
1 parent 62af3d6 commit d0bb05b

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"commit": "cz",
4747
"docs:preview": "docsify serve docs",
4848
"lint": "eslint ./ --ext .ts",
49-
"lint:fix": "npm run lint --fix",
49+
"lint:fix": "pnpm run lint --fix",
5050
"nodev": "node -v",
5151
"readme:copy": "echo \"<!-- DO NOT EDIT THIS FILE, EDIT MAIN README.md AND RUN \\`npm readme:copy\\` instead -->\n\n_Welcome to the docs site for_\n\" | cat - README.md > docs/README.md",
5252
"changelog": "auto-changelog --commit-limit false --unreleased-only --stdout",
@@ -60,7 +60,7 @@
6060
}
6161
},
6262
"dependencies": {
63-
"axios": "^1.4.0",
63+
"axios": "^1.7.6",
6464
"lodash": "^4.17.21"
6565
},
6666
"devDependencies": {
@@ -82,7 +82,7 @@
8282
"eslint-plugin-import": "^2.27.5",
8383
"eslint-plugin-jest": "^27.2.1",
8484
"eslint-plugin-no-floating-promise": "^1.0.2",
85-
"google-auth-library": "^9.2.0",
85+
"google-auth-library": "^9.14.0",
8686
"jest": "^29.5.0",
8787
"jest-junit": "^16.0.0",
8888
"release-it": "^15.11.0",

pnpm-lock.yaml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/GoogleSpreadsheet.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ type ExportFileTypes = keyof typeof EXPORT_CONFIG;
3333

3434
function getAuthMode(auth: GoogleApiAuth) {
3535
if ('getRequestHeaders' in auth) return AUTH_MODES.GOOGLE_AUTH_CLIENT;
36-
if ('token' in auth) return AUTH_MODES.RAW_ACCESS_TOKEN;
37-
if ('apiKey' in auth) return AUTH_MODES.API_KEY;
36+
if ('token' in auth && auth.token) return AUTH_MODES.RAW_ACCESS_TOKEN;
37+
// google-auth-library now has an empty `apiKey` property
38+
if ('apiKey' in auth && auth.apiKey) return AUTH_MODES.API_KEY;
3839
throw new Error('Invalid auth');
3940
}
4041

@@ -48,12 +49,12 @@ async function getRequestAuthConfig(auth: GoogleApiAuth) {
4849

4950
// API key only access passes through the api key as a query param
5051
// (note this can only provide read-only access)
51-
if ('apiKey' in auth) {
52+
if ('apiKey' in auth && auth.apiKey) {
5253
return { params: { key: auth.apiKey } };
5354
}
5455

5556
// RAW ACCESS TOKEN
56-
if ('token' in auth) {
57+
if ('token' in auth && auth.token) {
5758
return { headers: { Authorization: `Bearer ${auth.token}` } };
5859
}
5960

@@ -606,7 +607,7 @@ export class GoogleSpreadsheet {
606607
static async createNewSpreadsheetDocument(auth: GoogleApiAuth, properties?: Partial<SpreadsheetProperties>) {
607608
// see updateProperties for more info about available properties
608609

609-
if ('apiKey' in auth) {
610+
if (getAuthMode(auth) === AUTH_MODES.API_KEY) {
610611
throw new Error('Cannot use api key only to create a new spreadsheet - it is only usable for read-only access of public docs');
611612
}
612613

0 commit comments

Comments
 (0)