From 6b639403459a869a1e4ea9cdbe5f3af73c14d534 Mon Sep 17 00:00:00 2001 From: Hiromi Ishii Date: Thu, 19 May 2011 20:58:09 +0900 Subject: [PATCH] changed to see Response Status --- Web/Authenticate/OAuth.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Web/Authenticate/OAuth.hs b/Web/Authenticate/OAuth.hs index 22d98bf5..28e0bd8a 100644 --- a/Web/Authenticate/OAuth.hs +++ b/Web/Authenticate/OAuth.hs @@ -114,8 +114,12 @@ getAccessToken, getTokenCredential 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