I am trying to upload a file using react-native-google-drive-api-wrapper. I have created a project in the firebase console and able to google login and able to ask permission for accessing google drive. I have followed all the steps mentioned in the below link.
https://github.com/react-native-community/google-signin
Mentioned the below scopes in googleSignin.configure and in Google cloud console for this project. And getting the popup for asking the mentioned scopes while signing in. How can I resolve this error? Even I tried creating a folder but the same 403 for any google drive related requests. Is there any other configuration that I should do in the firebase console or 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',
});
Error is here below
{"_bodyBlob": {"_data": {"__collector": [Object], "blobId": "b86adcf1-c55a-4b08-8331-26475154af52", "offset": 0, "size": 962}}, "_bodyInit": {"_data": {"__collector": [Object], "blobId": "b86adcf1-c55a-4b08-8331-26475154af52", "offset": 0, "size": 962}}, "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"}
My code is here below. I am able to get true for GDrive.isInitialized() and all my parameters are proper.
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);
};
I am able to upload a file successfully. Error was due to insufficient access as mentioned in the question 403. As the below mentioned steps are not in the documentation of react-native-google-drive-api-wrapper and @react-native-community/google-signin, we should do this to enable the required apis.
Go to Google Cloud Console -> API & Services -> Select Project -> Click on Enable API and Services -> Search Drive -> Open Drive option -> Click on Enable API