浏览代码

fix token refresh (fix #978)

Gildas 3 年之前
父节点
当前提交
209a40491f
共有 2 个文件被更改,包括 4 次插入3 次删除
  1. 1 1
      src/core/bg/downloads.js
  2. 3 2
      src/lib/gdrive/gdrive.js

+ 1 - 1
src/core/bg/downloads.js

@@ -236,7 +236,7 @@ async function saveToGDrive(taskId, filename, blob, authOptions, uploadOptions)
 			} else {
 				await config.removeAuthInfo();
 			}
-			await saveToGDrive(taskId, filename, blob, authOptions, uploadOptions);
+			return await saveToGDrive(taskId, filename, blob, authOptions, uploadOptions);
 		} else {
 			throw new Error(error.message + " (Google Drive)");
 		}

+ 3 - 2
src/lib/gdrive/gdrive.js

@@ -82,7 +82,8 @@ class GDrive {
 				headers: { "Content-Type": "application/x-www-form-urlencoded" },
 				body: "client_id=" + this.clientId +
 					"&refresh_token=" + this.refreshToken +
-					"&grant_type=refresh_token"
+					"&grant_type=refresh_token" +
+					"&client_secret=" + this.clientKey
 			});
 			if (httpResponse.status == 400) {
 				throw new Error("unknown_token");
@@ -141,7 +142,7 @@ class GDrive {
 		try {
 			return {
 				cancelUpload: () => uploader.cancelled = true,
-				uploadPromise: uploader.upload()
+				uploadPromise: await uploader.upload()
 			};
 		}
 		catch (error) {