Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Good tutorial on Google Drive SDK and OAuth 2? [closed]

I want to be able to read in files on a website from a Google Drive account, which has made me pull my hair since the documentation for Google's services is so overwhelming (for me it is anyway, I have little experience with working with SDKs and APIs). I also realize that I need to use OAuth 2 authorization to grant access to the files. Any good ideas on where to start?

like image 819
Staffan Estberg Avatar asked Jan 07 '14 07:01

Staffan Estberg


1 Answers

Your first step is to decide whether you will be doing the Drive access from a Javascript client, or from a Web Server (php, Java, etc). OAuth is very different depending on which flow you will be using.

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

There are pros and cons to both methods. Personally I elected to use the low level HTTP APIs for the following reasons:-

  1. They are more stable. The libraries are prone to breaking changes which can frustrate beginners. Often you will find example code which won't compile v. the current library versions
  2. The less third party code I use, the easier it is for me to maintain
  3. I find some of the OAuth abstractions somewhat bizarre, especially in the error handling
  4. If you get errors, they can be difficult to resolve at the SDK level, and you find yourself needing to trace and hence understand the underlying HTTP API anyway.
  5. Many of the libraries are labelled Beta, which excludes them from production use in my company.

If you choose to go the HTTP API route, then there are really only three resources that you need.

  • Firstly, you need to understand OAuth https://developers.google.com/accounts/docs/OAuth2
  • Secondly, you need to validate your understanding using the OAuth playground https://developers.google.com/oauthplayground/
  • Finally, you can learn and watch the Drive API at (eg) https://developers.google.com/drive/v2/reference/files/list#try-it

Make sure you treat OAuth and Drive as separate topics. Understand OAuth first, then tackle Drive.

I'm sure a lot of people have success using the libs, so I won't write them off completely. They're just not for us for the reasons above.

One more tip, remember that OAuth is about Authorisation, not Authentication. So you still need to do your authentication and user/session management. Having said that, OAuth does spit out a user token as a by-product, so there is some overlap. My point is really that you need to roll your own user/session management.

like image 168
pinoyyid Avatar answered Sep 21 '22 07:09

pinoyyid