From 319747ca5cfa9dcafd5333f9d77b6479170746e9 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Fri, 6 Sep 2024 17:03:11 -0400 Subject: [PATCH] Debug --- .github/workflows/google-play/src/index.js | 1 + .../workflows/google-play/src/play-store-api.js | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/google-play/src/index.js b/.github/workflows/google-play/src/index.js index f134124..e128648 100644 --- a/.github/workflows/google-play/src/index.js +++ b/.github/workflows/google-play/src/index.js @@ -7,6 +7,7 @@ const PACKAGE_NAME = 'org.eternagame.mob'; const args = parseArgs(); const playStoreApi = await PlayStoreApi.create(args.apiKey); if (args.mode === 'upload') { + console.log('Starting Upload') const editId = await playStoreApi.insertEdit(PACKAGE_NAME); await playStoreApi.uploadBundle(PACKAGE_NAME, editId, args.bundlePath); await playStoreApi.commitEdit(PACKAGE_NAME, editId); diff --git a/.github/workflows/google-play/src/play-store-api.js b/.github/workflows/google-play/src/play-store-api.js index f44d7fd..f734a7a 100644 --- a/.github/workflows/google-play/src/play-store-api.js +++ b/.github/workflows/google-play/src/play-store-api.js @@ -41,8 +41,12 @@ export class PlayStoreApi { body: new URLSearchParams({ grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer', assertion: authToken - }).toString() + }).toString(), + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + } }); + console.log('Access token:', res.status, res.statusText); const parsed = await res.json(); return new PlayStoreApi(parsed['access_token']); } @@ -58,6 +62,7 @@ export class PlayStoreApi { Authorization: `Bearer ${this.accessToken}` } }); + console.log('Edit insert:', res.status, res.statusText); const parsed = await res.json(); return parsed['id']; } @@ -69,7 +74,7 @@ export class PlayStoreApi { */ async uploadBundle(packageName, editId, bundlePath) { const bundle = await readFile(bundlePath); - await fetch(`https://androidpublisher.googleapis.com/upload/androidpublisher/v3/applications/${packageName}/edits/${editId}/bundles?uploadType=media`, { + const res = await fetch(`https://androidpublisher.googleapis.com/upload/androidpublisher/v3/applications/${packageName}/edits/${editId}/bundles?uploadType=media`, { method: 'POST', headers: { Authorization: `Bearer ${this.accessToken}`, @@ -78,14 +83,17 @@ export class PlayStoreApi { }, body: bundle }); + if (res.status === 403) console.log(await res.json()) + console.log('Edit upload bundle:', res.status, res.statusText); } async commitEdit(packageName, editId) { - await fetch(`https://androidpublisher.googleapis.com/androidpublisher/v3/applications/${packageName}/edits/${editId}:commit`, { + const res = await fetch(`https://androidpublisher.googleapis.com/androidpublisher/v3/applications/${packageName}/edits/${editId}:commit`, { method: 'POST', headers: { Authorization: `Bearer ${this.accessToken}`, }, }); + console.log('Edit commit:', res.status, res.statusText); } } \ No newline at end of file