I was using v2 for ocr with increasing rate limit failures recently even with exponential backoff. As per DiesMan suggestion, switching to v3 fixed it for me. Changes I had to make:
- using Drive.Files.create() rather than Drive.Files.insert()
- no need for ocr: true option in v3
- had to explicitly set the mimetype to google doc when doing the create call to ocr the pdf to a google doc (with v2, insert() seemed to do this automatically when ocr set to true)
- change ‘title’ to ‘name’ in the file resource object
Drive API v2 and v3 comparison reference | Google Drive | Google for Developers was useful