From e762a42f23e17942adfe424751f5101b8c449fc2 Mon Sep 17 00:00:00 2001 From: Hiromi Ishii Date: Thu, 14 Jul 2011 19:51:43 +0900 Subject: [PATCH] Pulled some requests --- Web/Authenticate/OAuth.hs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Web/Authenticate/OAuth.hs b/Web/Authenticate/OAuth.hs index e929c14b..3b241f03 100644 --- a/Web/Authenticate/OAuth.hs +++ b/Web/Authenticate/OAuth.hs @@ -9,12 +9,12 @@ module Web.Authenticate.OAuth signOAuth, genSign, -- * Url & operation for authentication authorizeUrl, getAccessToken, getTemporaryCredential, - getTokenCredential, + getTokenCredential, getTemporaryCredentialWithScope, getAccessTokenProxy, getTemporaryCredentialProxy, - getTokenCredentialProxy, + getTokenCredentialProxy, getAccessToken', getTemporaryCredential', -- * Utility Methods - paramEncode + paramEncode, addScope, addMaybeProxy ) where import Network.HTTP.Enumerator import Web.Authenticate.Internal (qsUrl) @@ -94,6 +94,16 @@ getTemporaryCredential :: OAuth -- ^ OAuth Application -> IO Credential -- ^ Temporary Credential (Request Token & Secret). getTemporaryCredential = getTemporaryCredential' id +-- | Get temporary credential for requesting access token with Scope parameter. +getTemporaryCredentialWithScope :: BS.ByteString -- ^ Scope parameter string + -> OAuth -- ^ OAuth Application + -> IO Credential -- ^ Temporay Credential (Request Token & Secret). +getTemporaryCredentialWithScope = getTemporaryCredential' . addScope + +addScope :: (MonadIO m) => BS.ByteString -> Request m -> Request m +addScope scope req | BS.null scope = req + | otherwise = urlEncodedBody [("scope", scope)] req + -- | Get temporary credential for requesting access token via the proxy. getTemporaryCredentialProxy :: Maybe Proxy -- ^ Proxy -> OAuth -- ^ OAuth Application