May 16, 2019 David Hallinan Engineering, Guides, Storage API The Pitfalls of API Integration Services: Google Drive Edition“If you light a lamp for somebody, it will also brighten your path.” — BuddhaHere at Kloudless, tens of thousands of hours have been spent learning the intricacies of the APIs we provide connections with. Our developers have toiled long days and nights in the pursuit of a deep understanding of the services we allow applications to integrate with, not only in the aim of bolstering our own product but also for the self-betterment that comes with the true comprehension of an outside service. They say that mastery of a subject or profession comes with 10,000 hours of practice. If that much is true, we like to think we’ve mastered a couple of APIs at this point.In the vein of the quote that preceded this piece, we’d like to light the metaphorical lamp of API integrations for others that come after us. In this article, the first in a series of guides aimed to help you navigate the pitfalls of specific APIs, we will attempt to walk you through the trials and tribulations we went through when integrating with Google Drive, one of our more popular API offerings, in the hope that you can be prepared for the development speedbumps you might encounter while incorporating Google Drive into your application.Google’s Driving ForceGoogle Drive has cemented itself as one of the industry leaders in file storage and synchronization. Originally launched in 2012, Google Drive allows users to store files on their cloud servers, synchronize files across devices, and share files across its vast ecosystem of cloud applications. As one of the more robust offerings in the Google Suite of apps, Google Drive encompasses Google Docs, Google Sheets, and Google Slides. A major selling point of the Google Drive service is its ability to save files created and edited through other Google Suite applications, like the apps mentioned above.Google Drive has firmly made its name as an indispensable tool when it comes to cloud file storage services, and as a result, boasts almost a billion active users and over one million paying organizational users.The ProblemBesides the ability to simply store and share files and documents, an incredibly important aspect of Google Drive’s functionality is in its ability to monitor file synchronization. Every time a user updates a file or places a new file in their online drive, Google Drive records and relays that information as event info to stay in sync with the changes reflected in the cloud drive. Because of this operating procedure, a feature of major importance to Kloudless when integrating Google Drive into our Unified Storage API was being able to track events such as files being created or updated and relay that information to the user through our Events API.However, our engineers encountered an issue when trying to monitor for event data and map it to meaningful actions, as the Google Drive API had changed the way it returned event data to incorporate system events that were of no significance to the user event data that we needed to pass on to the user. On top of that, the event returns were unpredictable, with some actions returning identical event data despite a difference in user activity. These discrepancies in data patterns led to some confusingly unexpected returns from Google’s API.Finally, because Google Drive’s API is an industry leading cloud storage service API, they were constantly updating their versioning and leaving our engineers scrambling to incorporate the new changes in Google Drive’s functionality into our Unified Storage API.Users greatly benefit from these iterative updates in functionality on the provider’s side, but our engineers are then tasked with providing quick and thorough fixes for the now-outdated connectors before users can take advantage of the new features. Our Google Drive event connectivity was in dire need of a viable solution to these event issues that had presented themselves.The solutionJord Lin, an engineer at our Taipei location, was tasked with implementing the most recent fixes for our Google Drive connectors. In order to provide meaningful security audit support for our customers, Lin realized that his first task would have to be to tackle the problem of event pattern discrepancy. His solution was to implement a function to parse and then match the patterns of these event returns with the aim of eliminating unnecessary event data that had no relation to the event performed by the user. This consisted of breaking down events, extracting the relevant events, and then mapping them to a long list of user actions that are provided by the events API.By doing this, Lin could get rid of event data that served no viable purpose to our users, while properly mapping the relevant event data to a unified data model. Not only did this solve the immediate concerns of eliminating event data that was useless for our users, it properly set us up for the future as his function would parse and map data for any structural changes that might occur if there were more changes to the return dataIn ClosingLin not only provided a fix for the current issue we had encountered with the Google Drive API but he also set us up for success in the future. His algorithm to parse event data would allow both admin and regular user accounts to properly access the pertinent data while disregarding the trivial. Because Kloudless spends much of it’s development time updating connectors to accommodate changes in the source APIs, fixes like these are paramount.Often, updating functionality in API integrations is not exactly what you would call a “glamorous process.” There are a profound amount of things that can break when an API changes anything about the format of their returns and dealing with the ensuing chaos of broken functionality can be enough to make some developers throw in the towel. As a result, some developers and product managers choose to go with a unified API, such as Kloudless, for their integrations to save themselves the time and stress that goes along with updating functionality after an API update or versioning change. At the end of the day, however, Lin rose to the occasion and built an integral part of our Google Drive functionality in the Kloudless Unified Storage API. We hope that when deciding to incorporate Google Drive functionality into your application, you’ll go in prepared for what to expect thanks to Lin’s experience. We would love to hear from you about any pitfalls you’ve had while integrating with any of the APIs covered in this series. Please write to us at email@example.com and let us know any and all of the problems you may have encountered while wading through the swamp of API integrations. Please stay tuned for our next installment in the series, The Pitfalls of API Integration Services: HubSpot Edition.