oauthenticated 0.1.0 → 0.1.1
raw patch · 2 files changed
+11/−9 lines, 2 filesdep +textdep ~aeson
Dependencies added: text
Dependency ranges changed: aeson
Files
oauthenticated.cabal view
@@ -1,5 +1,5 @@ name: oauthenticated-version: 0.1.0+version: 0.1.1 synopsis: Simple OAuth for http-client description: @@ -52,7 +52,7 @@ Network.OAuth.MuLens Network.OAuth.Util build-depends: base >= 4.6 && < 4.7- , aeson >= 0.6.2 && < 0.7+ , aeson >= 0.6.2 && < 0.8 , base64-bytestring >= 1.0 && < 1.1 , blaze-builder >= 0.3 , bytestring >= 0.9@@ -66,6 +66,7 @@ , mtl >= 2.0 , network >= 2.3 , time >= 1.2+ , text >= 0.11 && < 1.2 , transformers hs-source-dirs: src
src/Network/OAuth/Types/Credentials.hs view
@@ -52,6 +52,7 @@ import Data.Monoid import Network.HTTP.Types (parseQuery, urlEncode) import Network.OAuth.Util+import Data.Text.Encoding (decodeLatin1, encodeUtf8) -- Constructors aren't exported. They're only used for derivation -- purposes.@@ -103,18 +104,18 @@ -- standard format for OAuth 1.0. instance FromJSON (Token ty) where parseJSON = withObject "OAuth Token" $ \o ->- Token <$> o .: "oauth_token"- <*> o .: "oauth_token_secret"+ Token <$> fmap encodeUtf8 (o .: "oauth_token")+ <*> fmap encodeUtf8 (o .: "oauth_token_secret") -- | Produces a JSON object using keys named @oauth_token@ and -- @oauth_token_secret@. instance ToJSON (Token ty) where- toJSON (Token k s) = object [ "oauth_token" .= k- , "oauth_token_secret" .= s+ toJSON (Token k s) = object [ "oauth_token" .= (decodeLatin1 k)+ , "oauth_token_secret" .= (decodeLatin1 s) ] --- | Parses a @www-form-urlencoded@ stream to produce a 'Token' if possible. --- The first result value is whether or not the token data is OAuth 1.0a +-- | Parses a @www-form-urlencoded@ stream to produce a 'Token' if possible.+-- The first result value is whether or not the token data is OAuth 1.0a -- compatible. -- -- >>> fromUrlEncoded "oauth_token=key&oauth_token_secret=secret"@@ -125,7 +126,7 @@ -- fromUrlEncoded :: S.ByteString -> Maybe (Bool, Token ty) fromUrlEncoded = tryParse . parseQuery where- tryParse q = do + tryParse q = do tok <- Token <$> lookupV "oauth_token" q <*> lookupV "oauth_token_secret" q confirmed <- lookupV "oauth_callback_confirmed" q <|> pure ""