This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE DeriveGeneric #-} | |
| {-# LANGUAGE OverloadedStrings #-} | |
| import GHC.Generics | |
| import Data.Aeson | |
| import Data.Text as T | |
| import Data.Aeson.Types | |
| data OAuth2Token = OAuth2Token { | |
| accessToken :: Text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE ScopedTypeVariables #-} | |
| {-# LANGUAGE DeriveGeneric #-} | |
| {-# LANGUAGE FlexibleContexts #-} | |
| {-# LANGUAGE TupleSections #-} | |
| {-# LANGUAGE RankNTypes #-} | |
| {-# LANGUAGE MultiParamTypeClasses #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| {-# LANGUAGE OverloadedStrings #-} | |
| module Network.OAuth.OAuth2.Services where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE ScopedTypeVariables #-} | |
| {-# LANGUAGE DeriveGeneric #-} | |
| {-# LANGUAGE FlexibleContexts #-} | |
| {-# LANGUAGE TupleSections #-} | |
| {-# LANGUAGE RankNTypes #-} | |
| {-# LANGUAGE MultiParamTypeClasses #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| {-# LANGUAGE OverloadedStrings #-} | |
| module Network.OAuth.OAuth2.Services where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/stack | |
| {- stack --install-ghc | |
| --resolver lts-8.13 | |
| script | |
| --compile | |
| --package text | |
| --package turtle | |
| --package attoparsec | |
| -} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data OAuth2Service m err = OAuth2Service { | |
| exchangeTokenUrl :: OAuth2 -> [Scope] -> StateToken -> URI | |
| , extractExchangeToken :: URI -> Either ExchangeTokenParseErrors (StateToken, ExchangeToken) | |
| , exchangeToken :: MonadResource m => OAuth2 -> ExchangeToken -> m (OAuth2Result TokenRequest.Errors OAuth2Token) | |
| , accessResource :: MonadResource m => OAuth2 -> AccessToken -> Request -> m (OAuth2Result err BS.ByteString) | |
| , refreshToken :: MonadResource m => OAuth2 -> RefreshToken -> m (OAuth2Result TokenRequest.Errors OAuth2Token) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import shapeless._ | |
| import shapeless.ops.hlist._ | |
| trait PromoteOption[L <: HList, T] extends DepFn1[L] with Serializable { type Out <: HList } | |
| object PromoteOption { | |
| def apply[L <: HList, U](implicit promote: PromoteOption[L, U]): Aux[L, U, promote.Out] = promote | |
| type Aux[L <: HList, U, Out0 <: HList] = PromoteOption[L, U] { type Out = Out0 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/stack | |
| {- stack --install-ghc | |
| runghc | |
| --package turtle | |
| --package attoparsec | |
| -} | |
| {-# LANGUAGE OverloadedStrings #-} | |
| {-# LANGUAGE RecordWildCards #-} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/stack | |
| {- stack --install-ghc | |
| runghc | |
| --package turtle | |
| --package attoparsec | |
| -} | |
| {-# LANGUAGE OverloadedStrings #-} | |
| {-# LANGUAGE RecordWildCards #-} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/stack | |
| {- stack --install-ghc | |
| runghc | |
| --package turtle | |
| --package attoparsec | |
| -} | |
| {-# LANGUAGE OverloadedStrings #-} | |
| {-# LANGUAGE RecordWildCards #-} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- file | |
| -- file:line | |
| -- file:line: | |
| -- file:line:row | |
| -- file:line:row: | |
| parseLocation :: Text -> Maybe FileLocation | |
| parseLocation = eitherToMaybe . parseOnly (do | |
| fileName <- P.takeWhile (== ':') | |
| (fileLine, fileCol) <- P.option (Nothing, Nothing) $ do | |
| P.string ":" |