Using Google Apps Script externally for Drive integration

I’m working on a web application that needs to connect with Google Drive using the Drive API. I noticed that Google Apps Script has some really useful API services that could help with this project.

My main question is whether I can use Google Apps Script code as an external library in my local HTML files, or do I have to write everything directly in the Google Apps Script editor? I’m hoping to keep my main codebase local while still taking advantage of the Apps Script functionality.

Also, if I do need to use the Apps Script editor, what’s the best way to connect it with the Drive API? I want to make sure I’m following the right approach for this integration.

yep grace is right about not being able to use it as a library locally. another option tho is just using the regular drive api directly in your web app instead of going through apps script. you’ll need to handle oauth yourself but google has pretty good documentation for it. might be simpler than creating that bridge setup if your comfortable with javascript and api calls.

Unfortunately, you cannot directly import Google Apps Script as an external library into your local HTML files. Apps Script runs on Google’s servers and the built-in services like DriveApp are only available within that environment. What you can do instead is create a web app or API endpoint using Apps Script that your local application can call via HTTP requests. I’ve done this approach several times and it works well - you basically use Apps Script as a bridge between your local app and Google services. For connecting to Drive API within Apps Script, you can use the built-in DriveApp service which handles authentication automatically, or use the advanced Drive API service if you need more granular control. The DriveApp service is simpler to work with since it doesn’t require manual OAuth handling.

The bridge approach mentioned earlier is definitely solid, but there’s another consideration worth mentioning. If you’re already building a web application, implementing the Drive API directly might give you more flexibility in the long run. I went down the Apps Script route initially for a similar project and found myself hitting limitations when I needed more complex file operations or wanted to integrate with other non-Google services. The authentication setup for Drive API isn’t as intimidating as it seems - Google’s client libraries handle most of the heavy lifting. You’ll need to set up OAuth 2.0 credentials in the Google Cloud Console and use the appropriate scope permissions. The main advantage is that everything stays within your codebase and you have full control over error handling and user experience. Apps Script is great for simple automation tasks, but for a full web application, the native API approach typically scales better.