How to enable Drive API using google Apps script in script editor

2.5k Views Asked by At

I am trying to enable Google Drive API using apps script so that we can upload any file to drive without manual intervention.

edit

function test()
{ 
var file = DriveApp.getFileById(newSpreadSheet.getId()); file.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.VIEW);
}

This is how I'm setting permission for a spreadsheet using code. I need a similar thing to enable drive API as well.So that anybody can use the spreadsheet without enabling the drive API manually from google developer console.

Thanks in advance

1

There are 1 best solutions below

0
On

Enabling an API is usually done through the Google Developer Console as given in enabling Google APIs Services wherein you enable them from the Google APIs Services dialog box from the Script Editor then through the Google APIs Console link.

However, if you don't want to go through the Developer Console, you may want to try Connecting to public APIs which is applicable for Google (or non-Google) API that isn't available as an Apps Script service. As mentioned,

If you want to use a Google (or non-Google) API that isn't available as an Apps Script service, you can connect to the API's public HTTP interface through the URL Fetch service.

Hope that helps!