Name: google-oauth2 Version: 0.2.1 Author: Pat Brisbin Maintainer: Pat Brisbin License: MIT License-File: LICENSE Synopsis: Google OAuth2 token negotiation Description: Interacting with the Google OAuth2 authorization API . 1. Prompt the user for a verification code 2. POST that code to the Google API for a set of tokens (access and refresh) 3. Use the access token until it expires 4. Use the refresh token to get a new access token 5. 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 = "..." . Cabal-Version: >= 1.10 Build-Type: Simple Library Default-Language: Haskell2010 HS-Source-Dirs: src GHC-Options: -Wall Exposed-Modules: Network.Google.OAuth2 Build-Depends: base >= 4 && < 5 , HTTP >= 4000.2 && < 4000.4 , aeson >= 0.8 && < 0.10 , bytestring , http-conduit Default-Extensions: OverloadedStrings RecordWildCards Test-Suite spec Type: exitcode-stdio-1.0 Default-Language: Haskell2010 Hs-Source-Dirs: test Ghc-Options: -Wall Main-Is: Spec.hs Build-Depends: base , google-oauth2 , hspec , bytestring , http-conduit , http-types , load-env Source-Repository head Type: git Location: https://github.com/pbrisbin/google-oauth2