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

Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup. #70

Closed NTJ3 closed 2 years ago

NTJ3 commented 2 years ago

@RobinBobin getting this error while downloading files from the drive.

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "dailyLimitExceededUnreg",
    "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
    "extendedHelp": "https://code.google.com/apis/console"
   }
  ],
  "code": 403,
  "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
 }
}
RobinBobin commented 2 years ago

Do you consider me a magus? I can't say anything without seeing a reproducible demo.

NTJ3 commented 2 years ago

Do you consider me a magus? I can't say anything without seeing a reproducible demo.

@RobinBobin

Retrieving files from google drive

GoogleSignin.addScopes({
        scopes: [
          'https://www.googleapis.com/auth/drive.readonly',
        ],
      }).then(async (val) => {
        const gdrive = new GDrive();
        gdrive.accessToken = (await GoogleSignin.getTokens()).accessToken

        const filesRes = await gdrive.files.list({
          fileds: 'files/mimeType',
          q: new ListQueryBuilder()
            .e('mimeType', 'application/pdf')
            .or()
            .e('mimeType', 'application/msword')
            .or()
            .e(
              'mimeType',
              'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
            ),

Download file one of google drive list

const gdrive = new GDrive();
      const queryParams = {
        // mimeType: item.mimeType,
        alt: 'media',
      };
      gdrive.accessToken = (await GoogleSignin.getTokens()).accessToken;

      // gdrive.permissions.create(item.id, queryParams);

      gdrive.files
        .get(item.id, queryParams)
        .then((res) => {
          console.log(res);

          const fileType =
            item.name.endsWith('.docx') || item.name.endsWith('.doc')
              ? 'word'
              : item.name.endsWith('.pdf')
              ? 'pdf'
              : '';

          const imagePath = `${RNFS.DownloadDirectoryPath}/${moment().valueOf()}.${fileType}`;

          RNFS.downloadFile({
            fromUrl: res.url,
            toFile: imagePath,
          })
RobinBobin commented 2 years ago

Are your scopes sufficient for downloading files?

You don't need rnfs to be able to download files. Have a look at my sample project linked in the docs.

NTJ3 commented 2 years ago

Yes scopes are correct.

NTJ3 commented 2 years ago

Are your scopes sufficient for downloading files?

You don't need rnfs to be able to download files. Have a look at my sample project linked in the docs.

@RobinBobin Yes scopes are correct, I can't download files implementation in your example project. Can you share the same if you have done il.

My requirement is to download files from Google Drive via your package is it possible?

RobinBobin commented 2 years ago

Yes, my package certainly can be used to download files.

The example project works for me. What problems are you facing when using it to download a file?

NTJ3 commented 2 years ago

@RobinBobin When I'm accessing url from

gdrive.files
        .get(item.id, queryParams)

it gives me this below error

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "dailyLimitExceededUnreg",
    "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
    "extendedHelp": "https://code.google.com/apis/console"
   }
  ],
  "code": 403,
  "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
 }
}

Can we have google meet?

RobinBobin commented 2 years ago

I think I'll be unavailable for a meet today.

Are you saying you launched my sample project and file downloading is giving you an error?

NTJ3 commented 2 years ago

No, I'm using url from below res


gdrive.files
        .get(item.id, queryParams)
RobinBobin commented 2 years ago

Try using my sample project. If it works for you, copy the code.

NTJ3 commented 2 years ago

@RobinBobin I tried your sample project I can't find code for download file. Could you pls share it if you know already?

RobinBobin commented 2 years ago

How about this?Screenshot_2022-06-08-13-38-54-32_4766d9c17ba12f4865821a14bb621a5d.jpg

NTJ3 commented 2 years ago

@RobinBobin This also didn't work.. It gives me Uint8Array but it's not convertible to any other form.

RobinBobin commented 2 years ago

That did work as expected. You can google to understand how to convert Uint8Array to js array.

NTJ3 commented 2 years ago

Yes, I did follow that only, That should return the file path. Not an Uint8Array

RobinBobin commented 2 years ago

What method should return a file path in your opinion?

NTJ3 commented 2 years ago

@RobinBobin This is not working in iOS

  const tokens = await GoogleSignin.getTokens();
 const gdrive = new GDrive();
 gdrive.accessToken = tokens.accessToken;
 gdrive.fetchTimeout = 4000;
gdrive.files.getBinary(item.id)

ERRR

ExceptionsManager.js:149 TypeError: Cannot read properties of undefined (reading 'length')
    at getLens (index.js:23:17)
    at toByteArray (index.js:55:14)
    at reader.onload (utils.ts:16:47)
    at FileReader.dispatchEvent (event-target-shim.js:818:35)
    at FileReader._setReadyState (FileReader.js:76:14)
    at FileReader.js:101:14
    at tryCallOne (core.js:37:12)
    at core.js:123:15
    at JSTimers.js:248:18
    at _callTimer (JSTimers.js:112:7)
RobinBobin commented 2 years ago

Does the sample project work in iOS?

RobinBobin commented 2 years ago

I'll close it, since it's been inactive for a while.