brendanhay/gogol

Add a simple example implementing authentication and few requests

Opened this issue · 4 comments

Would it be possible to add to examples a simple, runnable from console, example that shows how to (for example):

  1. Obtain OAuth URL for Web Application credentials (I don't see how formURL can do that)
  2. Open that URL in browser and let the user authorize the app and paste back the OAuthCode
  3. Using the authentication code retrieve the Access Token and Refresh Token
  4. Do simple request (for example fetch YouTube subscriptions) using the Access Token
  5. Using the Refresh Token acquire a new Access Token
  6. Do another request using the new Access Token

I've just spent a better part of a day trying to do something similar to this, but couldn't even get past authentication. For those well versed in advanced Haskell type magic they can probably put this together just reading type signatures, but for beginners it's practically impenetrable. Entire gogol-* system of libraries seems amazing and feature-full, but it's really hard to get started.

dgaw commented

@kmelva Did you get anywhere with this? I would really appreciate an example like you described.

@brendanhay this is something that I'd like to help with. It's scratching my own itch. Every newbie in my team has struggled with the gogol-* family of libraries. In fact, even I have spent the last couple of hours looking at http://hackage.haskell.org/package/gogol-0.3.0/docs/Network-Google-Auth.html and http://hackage.haskell.org/package/gogol-0.3.0/docs/Network-Google-Auth-InstalledApplication.html and have realised that Gogol doesn't really solve the "most common" use-case for server-side webapps: https://developers.google.com/identity/protocols/OAuth2WebServer

Is my understanding correct?

@brendanhay Is there any reason why http://hackage.haskell.org/package/gogol-0.3.0/docs/Network-Google-Auth.html#t:Credentials & http://hackage.haskell.org/package/gogol-0.3.0/docs/Network-Google-Auth-InstalledApplication.html#v:redirectURI can't be extended to also allow Gogol to support "Web Server Applications"?

I've spent quite some time today understanding how Gogol & Google-OAuth works, and feel that changing a few URL params here & there can get this to work. Shall I attempt a PR?