RobinBobin / react-native-google-drive-api-wrapper

This wrapper facilitates the use of the Google Drive API in React Native projects.
110 stars 43 forks source link

React-Native GDrive API "Error-> [AbortError: Aborted]" #80

Closed Zhongjie-Lin closed 1 year ago

Zhongjie-Lin commented 2 years ago

I'm using the @robinbobin/react-native-google-drive-api-wrapper for GDrive file access. I can sign in with the @react-native-google-signin/google-signin to get the access token. But when I try to access the google drive (tried gdrive.files.list({}) and gdrive.about.get('*')), I always get the "Error-> [AbortError: Aborted]" with the "LOG" tag due to timeout.

LOG Error-> [AbortError: Aborted]

I've also tried the RobinBobin/gdrivetest project from https://github.com/RobinBobin/gdrivetest. Still got the same "Error-> [AbortError: Aborted]" message.

Any help is appreciated!

Related Code:

 // Signin configure
 GoogleSignin.configure({
  scopes: [
    'https://www.googleapis.com/auth/drive',
    'https://www.googleapis.com/auth/drive.appdata',
    'https://www.googleapis.com/auth/drive.metadata',
    'https://www.googleapis.com/auth/drive.scripts',
    'https://www.googleapis.com/auth/drive.file',
    'https://www.googleapis.com/auth/drive.appfolder',
    'https://www.googleapis.com/auth/drive.appdata',
    'https://www.googleapis.com/auth/drive.metadata',
    'https://www.googleapis.com/auth/drive.readonly',
    'https://www.googleapis.com/auth/drive.metadata.readonly',
    'https://www.googleapis.com/auth/drive.apps.readonly',
    'https://www.googleapis.com/auth/drive.photos.readonly',
    'https://www.googleapis.com/auth/drive.activity',
    'https://www.googleapis.com/auth/drive.activity.readonly'
  ],
});

// GDrive access
const gdrive = new GDrive();
gdrive.accessToken = (await GoogleSignin.getTokens()).accessToken;
gdrive.fetchCoercesTypes = true;
gdrive.fetchRejectsOnHttpErrors = true;
gdrive.fetchTimeout = 30000;
console.log(await gdrive.about.get('*'));

// Tried this as well
let data = await gdrive.files.list({
  q: new ListQueryBuilder()
     .e('folderId', '1cU1OKC9K20DivHcdMeIhwMWGThIudLEB')
      .in('root', 'parents'),
});

Google Drive API Setup:

Enabled APIs:

Google Drive API        
App Engine Admin API                    
BigQuery API                    
BigQuery Migration API                  
BigQuery Storage API                    
Cloud Datastore API                 
Cloud Debugger API                  
Cloud Logging API                   
Cloud Monitoring API                    
Cloud Pub/Sub API                   
Cloud Resource Manager API                  
Cloud Runtime Configuration API                 
Cloud SQL                   
Cloud Storage                   
Cloud Storage API                   
Cloud Testing API                   
Cloud Trace API                 
FCM Registration API                    
Firebase App Distribution API                   
Firebase Cloud Messaging API                    
Firebase Dynamic Links API                  
Firebase Hosting API                    
Firebase Installations API                  
Firebase Management API                 
Firebase Remote Config API                  
Firebase Rules API                  
Google Cloud APIs                   
Google Cloud Storage JSON API                   
Identity Toolkit API                    
Mobile Crash Reporting API                  
Service Management API                  
Service Usage API                   
Token Service API
RobinBobin commented 2 years ago

Try increasing fetch timeout. Looks like your internet connection isn't perfect.

manikanta700 commented 2 years ago

Same error for me also.. It is working fine in some cases but in most cases it is given Abort error

Zhongjie-Lin commented 2 years ago

@RobinBobin Your comment gives me some idea. I was using the android simulator to test the app and it always gives the AbortError, but when I switch to my cell phone, everything seems working fine at least for now.

sam-uraii commented 2 years ago

const gdrv = new GDrive() gdrv.fetchTimeout = 3000 // or more //actually the default is 1500 and this can be a bit small time for timeout so, always increase the fetchtimout according to //your use case.

Zhongjie-Lin commented 2 years ago

Thanks @sam-uraii for your comment! However, in my last trial on the simulator, I set this value to 300000 and it still yields a AbortError for me.

sam-uraii commented 2 years ago

ohhhh!!! then the AbortError should be more explanatory...

manikanta700 commented 2 years ago

Thanks @sam-uraii my error solved by giving gdrive.fetchTimeout = 3000

sam-uraii commented 2 years ago

@manikanta700 welcome...