(maybe) resolved oauth-1.0 problem
This commit is contained in:
parent
30f6348e56
commit
df89f0c312
@ -48,19 +48,29 @@ authOAuth oauth mkCreds = AuthPlugin name dispatch login
|
|||||||
setSession oauthSessionName $ lookupTokenSecret tok
|
setSession oauthSessionName $ lookupTokenSecret tok
|
||||||
redirect $ authorizeUrl oauth' tok
|
redirect $ authorizeUrl oauth' tok
|
||||||
dispatch "GET" [] = do
|
dispatch "GET" [] = do
|
||||||
(verifier, oaTok) <- runInputGet $ (,)
|
reqTok <-
|
||||||
<$> ireq textField "oauth_verifier"
|
if oauthVersion oauth == OAuth10
|
||||||
<*> ireq textField "oauth_token"
|
then do
|
||||||
tokSec <- fromJust <$> lookupSession oauthSessionName
|
oaTok <- runInputGet $ ireq textField "oauth_token"
|
||||||
deleteSession oauthSessionName
|
tokSec <- fromJust <$> lookupSession oauthSessionName
|
||||||
let reqTok = Credential [ ("oauth_verifier", encodeUtf8 verifier)
|
deleteSession oauthSessionName
|
||||||
|
return $ Credential [ ("oauth_token", encodeUtf8 oaTok)
|
||||||
|
, ("oauth_token_secret", encodeUtf8 tokSec)
|
||||||
|
]
|
||||||
|
else do
|
||||||
|
(verifier, oaTok) <-
|
||||||
|
runInputGet $ (,) <$> ireq textField "oauth_verifier"
|
||||||
|
<*> ireq textField "oauth_token"
|
||||||
|
tokSec <- fromJust <$> lookupSession oauthSessionName
|
||||||
|
deleteSession oauthSessionName
|
||||||
|
return $ Credential [ ("oauth_verifier", encodeUtf8 verifier)
|
||||||
, ("oauth_token", encodeUtf8 oaTok)
|
, ("oauth_token", encodeUtf8 oaTok)
|
||||||
, ("oauth_token_secret", encodeUtf8 tokSec)
|
, ("oauth_token_secret", encodeUtf8 tokSec)
|
||||||
]
|
]
|
||||||
master <- getYesod
|
master <- getYesod
|
||||||
accTok <- lift $ getAccessToken oauth reqTok (authHttpManager master)
|
accTok <- lift $ getAccessToken oauth reqTok (authHttpManager master)
|
||||||
creds <- resourceLiftBase $ mkCreds accTok
|
creds <- resourceLiftBase $ mkCreds accTok
|
||||||
setCreds True creds
|
setCreds True creds
|
||||||
dispatch _ _ = notFound
|
dispatch _ _ = notFound
|
||||||
login tm = do
|
login tm = do
|
||||||
render <- lift getUrlRender
|
render <- lift getUrlRender
|
||||||
@ -80,6 +90,7 @@ authTwitter key secret = authOAuth
|
|||||||
, oauthSignatureMethod = HMACSHA1
|
, oauthSignatureMethod = HMACSHA1
|
||||||
, oauthConsumerKey = key
|
, oauthConsumerKey = key
|
||||||
, oauthConsumerSecret = secret
|
, oauthConsumerSecret = secret
|
||||||
|
, oauthVersion = OAuth10a
|
||||||
})
|
})
|
||||||
extractCreds
|
extractCreds
|
||||||
where
|
where
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: yesod-auth-oauth
|
name: yesod-auth-oauth
|
||||||
version: 0.8.0
|
version: 0.8.1
|
||||||
license: BSD3
|
license: BSD3
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Hiromi Ishii
|
author: Hiromi Ishii
|
||||||
@ -21,7 +21,7 @@ library
|
|||||||
cpp-options: -DGHC7
|
cpp-options: -DGHC7
|
||||||
else
|
else
|
||||||
build-depends: base >= 4 && < 4.3
|
build-depends: base >= 4 && < 4.3
|
||||||
build-depends: authenticate-oauth >= 1.0 && < 1.1
|
build-depends: authenticate-oauth >= 1.1 && < 1.2
|
||||||
, bytestring >= 0.9.1.4 && < 0.10
|
, bytestring >= 0.9.1.4 && < 0.10
|
||||||
, yesod-core >= 0.10 && < 0.11
|
, yesod-core >= 0.10 && < 0.11
|
||||||
, yesod-auth >= 0.8 && < 0.9
|
, yesod-auth >= 0.8 && < 0.9
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user