packages feed

authenticate 0.9.0.2 → 0.9.1

raw patch · 2 files changed

+15/−7 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Web.Authenticate.OAuth: OAuthException :: String -> OAuthException
+ Web.Authenticate.OAuth: data OAuthException

Files

Web/Authenticate/OAuth.hs view
@@ -2,7 +2,7 @@ {-# OPTIONS_GHC -Wall -fno-warn-orphans #-} module Web.Authenticate.OAuth     ( -- * Data types-      OAuth(..), SignMethod(..), Credential(..),+      OAuth(..), SignMethod(..), Credential(..), OAuthException(..),       -- * Operations for credentials       emptyCredential, insert, delete, inserts,       -- * Signature@@ -38,6 +38,7 @@ import Data.Monoid (mconcat) import Control.Monad.IO.Class (MonadIO (liftIO)) import Data.IORef (newIORef, readIORef, atomicModifyIORef)+import Control.Exception (Exception, throwIO)  -- | Data type for OAuth client (consumer). data OAuth = OAuth { oauthServerName      :: String        -- ^ Service name@@ -75,7 +76,7 @@ token = fromMaybe "" . lookup "oauth_token" . unCredential tokenSecret = fromMaybe "" . lookup "oauth_token_secret" . unCredential -data OAuthException = ProtocolException String+data OAuthException = OAuthException String                       deriving (Show, Eq, Data, Typeable)  instance Exception OAuthException@@ -93,8 +94,11 @@   let req = fromJust $ parseUrl $ oauthRequestUri oa   req' <- signOAuth oa emptyCredential (req { method = "POST" })    rsp <- withManager $ httpLbs req'-  let dic = parseSimpleQuery . toStrict . responseBody $ rsp-  return $ Credential dic+  if statusCode rsp == 200+    then do+      let dic = parseSimpleQuery . toStrict . responseBody $ rsp+      return $ Credential dic+    else throwIO . OAuthException $ "Gaining OAuth Temporary Credential Failed: " ++ BSL.unpack (responseBody rsp)  -- | URL to obtain OAuth verifier. authorizeUrl :: OAuth           -- ^ OAuth Application@@ -110,8 +114,12 @@ getAccessToken oa cr = do   let req = (fromJust $ parseUrl $ oauthAccessTokenUri oa) { method = "POST" }   rsp <- signOAuth oa cr req >>= withManager . httpLbs-  let dic = parseSimpleQuery . toStrict . responseBody $ rsp-  return $ Credential dic+  if statusCode rsp == 200+    then do+      let dic = parseSimpleQuery . toStrict . responseBody $ rsp+      return $ Credential dic+    else throwIO . OAuthException $ "Gaining OAuth Temporary Credential Failed: " ++ BSL.unpack (responseBody rsp)+  getTokenCredential = getAccessToken 
authenticate.cabal view
@@ -1,5 +1,5 @@ name:            authenticate-version:         0.9.0.2+version:         0.9.1 license:         BSD3 license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>