hoauth2 0.3.6.1 → 0.3.7
raw patch · 4 files changed
+16/−13 lines, 4 files
Files
- example/Facebook/test.hs +1/−1
- example/Github/test.hs +1/−1
- hoauth2.cabal +1/−1
- src/Network/OAuth/OAuth2/HttpClient.hs +13/−10
example/Facebook/test.hs view
@@ -39,7 +39,7 @@ putStrLn "visit the url and paste code here: " code <- fmap BS.pack getLine let (url, body) = accessTokenUrl facebookKey code- (Right token) <- doJSONPostRequest url (body ++ [("state", "test")])+ (Right token) <- doJSONPostRequest facebookKey url (body ++ [("state", "test")]) userinfo token >>= print userinfo' token >>= print
example/Github/test.hs view
@@ -32,7 +32,7 @@ putStrLn "visit the url and paste code here: " code <- getLine let (url, body) = accessTokenUrl githubKey (sToBS code)- token <- doJSONPostRequest url (body ++ [("state", state)])+ token <- doJSONPostRequest githubKey url (body ++ [("state", state)]) print (token :: OAuth2Result AccessToken) case token of Right at -> userInfo at >>= print
hoauth2.cabal view
@@ -1,6 +1,6 @@ Name: hoauth2 -- (http://www.haskell.org/haskellwiki/Package_versioning_policy)-Version: 0.3.6.1+Version: 0.3.7 Synopsis: hoauth2 Description:
src/Network/OAuth/OAuth2/HttpClient.hs view
@@ -25,7 +25,7 @@ fetchAccessToken :: OAuth2 -- ^ OAuth Data -> BS.ByteString -- ^ Authentication code gained after authorization -> IO (OAuth2Result AccessToken) -- ^ Access Token-fetchAccessToken oa code = doJSONPostRequest uri body+fetchAccessToken oa code = doJSONPostRequest oa uri body where (uri, body) = accessTokenUrl oa code @@ -33,26 +33,29 @@ fetchRefreshToken :: OAuth2 -- ^ OAuth context -> BS.ByteString -- ^ refresh token gained after authorization -> IO (OAuth2Result AccessToken)-fetchRefreshToken oa rtoken = doJSONPostRequest uri body+fetchRefreshToken oa rtoken = doJSONPostRequest oa uri body where (uri, body) = refreshAccessTokenUrl oa rtoken -- | Conduct post request and return response as JSON. doJSONPostRequest :: FromJSON a- => URI -- ^ The URL+ => OAuth2+ -> URI -- ^ The URL -> PostBody -- ^ request body -> IO (OAuth2Result a) -- ^ Response as ByteString-doJSONPostRequest uri body = liftM parseResponseJSON (doSimplePostRequest uri body)+doJSONPostRequest oa uri body = liftM parseResponseJSON (doSimplePostRequest oa uri body) -- | Conduct post request.-doSimplePostRequest :: URI -- ^ URL+doSimplePostRequest :: OAuth2+ -> URI -- ^ URL -> PostBody -- ^ Request body. -> IO (OAuth2Result BSL.ByteString) -- ^ Response as ByteString-doSimplePostRequest url body = liftM handleResponse go- where go = do- req <- parseUrl $ BS.unpack url- let req' = updateRequestHeaders Nothing req- withManager $ httpLbs (urlEncodedBody body req')+doSimplePostRequest oa url body = liftM handleResponse go+ where go = do+ req <- parseUrl $ BS.unpack url+ let addBasicAuth = applyBasicAuth (oauthClientId oa) (oauthClientSecret oa)+ req' = (addBasicAuth . updateRequestHeaders Nothing) req+ withManager $ httpLbs (urlEncodedBody body req') -------------------------------------------------- -- * AUTH requests