google-oauth2: Google OAuth2 token negotiation
Interacting with the Google OAuth2 authorization API
Prompt the user for a verification code
POST that code to the Google API for a set of tokens (access and refresh)
Use the access token until it expires
Use the refresh token to get a new access token
Repeat from 3
Example usage:
import Data.Monoid import Network.Google.OAuth2 import Network.HTTP.Conduit import Network.HTTP.Types (hAuthorization) import qualified Data.ByteString.Char8 as B8 import qualified Data.ByteString.Lazy.Char8 as L8 main :: IO () main = do let client = OAuth2Client clientId clientSecret scopes = ["https://www.googleapis.com/auth/drive"] token <- getAccessToken client scopes Nothing request <- parseUrl "https://www.googleapis.com/drive/v2/files" response <- withManager $ httpLbs $ authorize token request L8.putStrLn $ responseBody response where authorize token request = request -- Note: haddock chokes on curly braces for some reason, so I'm using -- parens here instead. ( requestHeaders = [(hAuthorization, B8.pack $ "Bearer " <> token)] ) -- Setup in Google Developers Console clientId = "..." clientSecret = "..."
Downloads
- google-oauth2-0.1.0.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
Versions [RSS] | 0.1.0, 0.2.0, 0.2.1, 0.2.2, 0.3.0.0 |
---|---|
Dependencies | aeson (>=0.8 && <0.9), base (>=4 && <5), bytestring, HTTP (>=4000.2 && <4000.3), http-conduit [details] |
License | MIT |
Author | Pat Brisbin <pbrisbin@gmail.com> |
Maintainer | Pat Brisbin <pbrisbin@gmail.com> |
Source repo | head: git clone https://github.com/pbrisbin/google-oauth2 |
Uploaded | by PatrickBrisbin at 2014-11-13T23:30:22Z |
Distributions | |
Reverse Dependencies | 1 direct, 0 indirect [details] |
Downloads | 3813 total (4 in the last 30 days) |
Rating | (no votes yet) [estimated by Bayesian average] |
Your Rating | |
Status | Docs uploaded by user Build status unknown [no reports yet] |