Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pbrisbin/google-oauth2
Google OAuth2 token negotiation
https://github.com/pbrisbin/google-oauth2
Last synced: about 2 months ago
JSON representation
Google OAuth2 token negotiation
- Host: GitHub
- URL: https://github.com/pbrisbin/google-oauth2
- Owner: pbrisbin
- License: mit
- Created: 2014-11-13T23:09:16.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2021-03-17T12:56:24.000Z (almost 4 years ago)
- Last Synced: 2024-11-02T09:42:15.767Z (about 2 months ago)
- Language: Haskell
- Homepage:
- Size: 27.3 KB
- Stars: 9
- Watchers: 4
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.hs
- License: LICENSE
Awesome Lists containing this project
README
# Google OAuth2
Interactive Google OAuth2 token negotiation
## Usage
```haskell
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}module Main (main) where
import Data.Aeson
import Data.Semigroup ((<>))
import Network.Google.OAuth2
import Network.HTTP.Simple
import Network.OAuth.OAuth2
import Data.Text.Encoding (encodeUtf8)main :: IO ()
main = do
OAuth2Token{..} <-
getAccessToken
"" -- Fill with real ID.
"" -- Fill with real code.
["https://www.googleapis.com/auth/drive"]
(Just "path/to/credentials.cache")request <- parseRequest "https://www.googleapis.com/drive/v2/files"
response <- httpJSON $ authorize (atoken accessToken) requestprint (getResponseBody response :: Value)
where
authorize token = setRequestHeaders
[ ("Authorization", encodeUtf8 $ "Bearer " <> token)
]
```## Prior Art
This module was inspired by [handa-gdata][] which appears to be abandoned.
[handa-gdata]: http://hackage.haskell.org/package/handa-gdata
---
[CHANGELOG](./CHANGELOG.md) | [LICENSE](./LICENSE)