Jump to content
Sign in to follow this  
Guest

Google Drive API (Rant Coming)

Recommended Posts

Guest

I'm an old school programmer, having started out in the early 70's when I was a kid. Back then, resources were practically non-existent, so any code absolutely had to be compact, reusable (and later, object oriented) and to me at least, elegant in design and function. 

That said, I was working on a project for my EFL school, which involved writing out exam data to Google Sheets I have set up in my Drive account. I knew that Google had a very robust API for this, so assumed it would be a piece of cake. I've experimented with their API in the past, but never really had a need to use it until now. 

So, I go over to Google's API Console, create a project, enable the Sheets API and get an API Key for my project. After a couple of failed tests and more reading, I finally figured out that API Keys don't work on Private Data - only Public Data, and I don't want the Sheets to be publicly available for student privacy reasons. 

Google also offers Oauth 2.0 as well as a Service Account for authentication, but all of their documentation is geared towards their API Client (SDK) platform. After doing a bit more research I ended up installing Composer and then the API Client (about 12 MB's of bloated code). After running their initial authentication process successfully, I turned to writing and updating cell values, which ended up an epic fail, with constant errors or false positives (Google said the data was written, but it wasn't there).

Sidebar: If I were going to release this as a commercial product, I don't see many customers having the skill set to install and configure everything Google wants via SSH. 

One of the problems I kept encountering was having to manually give permission to access my Sheets, which, in turn, would require me to be logged into Google anywhere the script was running (student computers at my school). What was frustrating is that I wanted to access my own private data, not anyone else's and I didn't want the students to have to go through these extra steps. 

Finally, I got so irritated that I dumped everything and decided to write my own authentication and update routine to write out the Sheets payload as needed. I eventually settled on using the Service Account option for authentication and processed everything using CURL. 

The end result: 30 lines of code later I was successfully authenticating and updating the Sheets exactly how I needed to do it.

I've done the same thing with other SDK's, like Twillio, Amazon, Authorize Net and PayPal to name a few, because on more than one occasion I've been slammed with complaints about apps failing because the SDK's were updated and the old ones arbitrarily depreciated with no warning (PayPal does this).

To me, a good API just requires a clearly defined authentication process along with straightforward methods to read and write data. As in my case, a 37K script should NOT require a back end of 12 MB's of supporting scripts to do something so simple.

I'm going to experiment a bit more with this on other Google Drive Apps and see how it works, although I don't foresee any problems. I'm just shaking my head in astonishment that Google doesn't offer up something this simple to begin with. 

Anyways, that's the end of my rant - problem solved (and it's a very elegant solution). 

Does anyone else here use the Google API? I'm just curious about your experiences with it...

Share this post


Link to post
Share on other sites

SEMrush

You're begging for trouble using any API. You'll wake up one day and find out it's being discontinued. Guaranteed.

Even Google is notorious for giving up on products/APIs.

 

  • Freebase API
  • Google Feed API
  • Google Chart API
  • Google Friend Connect API
  • etc...

 

Share this post


Link to post
Share on other sites
Guest
1 hour ago, yukon said:

You're begging for trouble using any API. You'll wake up one day and find out it's being discontinued. Guaranteed.

Even Google is notorious for giving up on products/APIs.

 

  • Freebase API
  • Google Feed API
  • Google Chart API
  • Google Friend Connect API
  • etc...

 

I don't think I can agree with that first statement - a lot of third-party services can't be utilized without them. The only alternative is scraping or automating something directly through the webpage, and those tend to change far more often than API's do. 

Yes, I get they can be discontinued, but for the most part, at least the ones I use regularly have been around for many years with no indication of being discontinued. 

Just out of curiosity, what do you use instead of API's? 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.