0
votes

I have created an API for sending letters. My letters are on google drive. I have created an API that uses my pdf files saved on a google drive account. So the API has a loop according to a number of letters. If I have 1000 records API will take 1000 files from google drive for every record already saved in a specific folder. I'm not using any API for downloading files from google drive. I'm using this link for getting files https://drive.google.com/uc?id=FILE_ID&format=pdf or https://drive.google.com/uc?id=FILE_ID&authuser=0&export=download

$query_str = explode('/', $fileURL); $fileID = $query_str[5]; $parrsedURL = "https://drive.google.com/uc?id=".$fileID;

file_put_contents('ClientFiels/'.$fileName.'.pdf', fopen($fileURL, 'r'));

*FILE_ID id will be changed every time the new round of loop will start. Problem: The API is working fine for 60 to 70 records. And after that, I'm getting this error. 403 for URL: https://doc-00-5o-docs.googleusercontent.com/docs/securesc/ha0ro937gcuc7l7deffksulhg5h7mbp1/576qj60mg7jp9jdrko5ck1dtabf1ktm3/1647339525000/09925282465490487763/*/1V1AYJRwLcZxSoAFJPRzuOEMFWiKiptb4?e=download And after 5 to 10 minutes if I run the program again it works for the same amount of records again. When I check my API metrics in google console it shows me an error in Drive.files.copy: method. I tried to download files in different ways but I got the same error. I'm not sure if there is any quota limit or I need to change any settings. Google Drive files and folders are public.

It doesn't look like you're hitting a quota limit as that should return a 429 instead of a 403. 403 means you do not have access to the file you're trying to access. Try skipping over the file that returns the 403 and see if you can get the rest of the files in your list.Edo Akse