Good tutorial on Google Drive SDK and OAuth 2?

I want to be able to read files on a website from a Google Drive account, which made me pull my hair out as the documentation for Google services is so overwhelming (for me it is anyway, I have little experience with the SDK and API). I also understand that I need to use OAuth 2 authorization to provide file access. Any good ideas on where to start?

+8
google-drive-sdk google-oauth
source share
3 answers

Your first step is to decide whether you will make access to the disk using the Javascript client or from a web server (php, Java, etc.). OAuth is very different depending on which stream you use.

Your second step is to decide whether you want to use the abstraction libraries or directly access the HTTP API.

There are pros and cons for both methods. Personally, I decided to use a low-level HTTP API for the following reasons: -

  • They are more stable. Libraries are prone to disruptions that can interfere with beginners. Often you will find sample code that will not compile v. Current library versions
  • The less third-party code I use, the easier it is for me to maintain
  • I find some OAuth abstractions somewhat bizarre, especially in error handling
  • If you get errors, it can be difficult to resolve them at the SDK level and you will find that you need to track and therefore understand the basic HTTP API.
  • Many of the libraries are marked as beta, which excludes them from production at my company.

If you decide to follow the HTTP API route, then you only need three resources.

Make sure you consider OAuth and Drive as separate topics. Get to know OAuth first, then apply Drive.

I am sure that many people have success using lib, so I won’t write them off completely. They are simply not for us for the reasons above.

One more tip, remember that OAuth is authorization, not authentication. Thus, you still need to authenticate and manage users / sessions. Having said what OAuth does , spits out the user token as a by-product, so there is some overlap. I want to say that you need to minimize your own user / session management.

+15
source share

On these slides at the end there is an example with OAuth.io for synchronizing a file with Google, this can help you

The source code for this demo is available on github.

+5
source share

There is a good code example that you can find out on this site. It includes demo html files, and the api runs exclusively in javascript.

https://bytutorial.com/tutorials/google-api/introduction-to-google-drive-api-using-javascript

-one
source share

All Articles