403,同时使用react-native-google-drive-api-wrapper将文件上传到Google云端硬盘

我正在尝试使用 react-native-google-drive-api-wrapper 上传文件。我已经在Firebase控制台中创建了一个项目,并且能够通过Google登录并可以请求访问Google驱动器的权限。我已经按照以下链接中提到的所有步骤进行操作。

https://github.com/react-native-community/google-signin

在此项目的googleSignin.configure和Google云控制台中提到了以下作用域。并在登录时弹出询问您所提到的范围的弹出窗口。如何解决此错误?即使我尝试创建一个文件夹,但对于任何与Google Drive相关的请求都使用相同的403。我应该在Firebase控制台或Google Cloud Console中进行其他配置吗?

        GoogleSignin.configure({
            scopes: ['https://www.googleapis.com/auth/drive','https://www.googleapis.com/auth/drive.metadata',"https://www.googleapis.com/auth/drive.appfolder",],shouldFetchBasicProfile: true,webClientId: 'My client id',});

错误在下面

{"_bodyBlob": {"_data": {"__collector": [Object],"blobId": "b86adcf1-c55a-4b08-8331-26475154af52","offset": 0,"size": 962}},"_bodyInit": {"_data": {"__collector": [Object],"headers": {"map": {"alt-svc": "h3-29=\":443\"; ma=2592000,h3-27=\":443\"; ma=2592000,h3-25=\":443\"; ma=2592000,h3-T050=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"","content-length": "962","content-type": "application/json; charset=UTF-8","date": "Thu,02 Jul 2020 09:20:30 GMT","server": "UploadServer","vary": "Origin,X-Origin","x-guploader-uploadid": "AAANsUkDhtWsnzNrl9JlD3Rj4Qz4Q5skrcdPX85Bmzg6i4mU3McC3xY7vhrJ-7OoSCHtDhfRrYnfo4N9RES7c77Faw"}},"ok": false,"status": 403,"statusText": undefined,"type": "default","url": "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart"}

我的代码在下面。我能够对GDrive.isInitialized()正确,并且我所有的参数都正确。

    GDrive.setaccessToken(token.accessToken);
    GDrive.init();
    GDrive.isInitialized() ? console.log(true) : console.log(false);
    GDrive.files
          .createFileMultipart(
            this.state.filebase64,"image/jpg",{
              parents: ['root'],//or any path
              name: "newImage.jpg",},true,)
          .then(a => {
            console.log(a);
          }).catch = err => {
            console.log('error',err);
          };
iCMS 回答:403,同时使用react-native-google-drive-api-wrapper将文件上传到Google云端硬盘

我能够成功上传文件。错误是由于问题403中所述的访问不足而导致的。由于以下提到的步骤不在react-native-google-drive-api-wrapper和@ react-native-community / google-signin的文档中,启用所需的api。

转到Google Cloud Console-> API和服务->选择项目-> 单击启用API和服务->搜索驱动器->打开驱动器选项->单击启用API

本文链接:https://www.f2er.com/2014235.html

大家都在问