brendanhay / gogol

A comprehensive Google Services SDK for Haskell.
Other
281 stars 105 forks source link

Add a simple example implementing authentication and few requests #92

Open klozovin opened 6 years ago

klozovin commented 6 years ago

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 6 years ago

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

saurabhnanda commented 6 years ago

@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?

saurabhnanda commented 6 years ago

@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?

NorfairKing commented 5 years ago

@saurabhnanda +1 on this

tonicebrian commented 4 days ago

Hi @saurabhnanda I'm collaborating in getting Gogol in shape. If you are still thinking about contributing, please create a PR and I will have a look at it.