Fix Facebook code

This commit is contained in:
Michael Snoyman 2011-06-09 16:33:38 +03:00
parent f3997728f6
commit 6232f52aa0
3 changed files with 8 additions and 6 deletions

View File

@ -60,6 +60,7 @@ accessTokenUrl fb code =
[ ("client_id", Just $ facebookClientId fb)
, ("redirect_uri", Just $ facebookRedirectUri fb)
, ("code", Just code)
, ("client_secret", Just $ facebookClientSecret fb)
]
getAccessToken :: Facebook -> Text -> IO AccessToken

View File

@ -16,7 +16,7 @@ homepage: http://github.com/snoyberg/authenticate/tree/master
library
build-depends: base >= 4 && < 5,
aeson >= 0.3.1.1 && < 0.4,
http-enumerator >= 0.6 && < 0.7,
http-enumerator >= 0.6.5.2 && < 0.7,
tagsoup >= 0.6 && < 0.13,
failure >= 0.0.0 && < 0.2,
transformers >= 0.1 && < 0.3,

View File

@ -22,23 +22,24 @@ instance Yesod FB where approot _ = "http://localhost:3000"
getRootR = do
FB f <- getYesod
let s = encodeUtf8 $ getForwardUrl f ["email"]
let s = getForwardUrl f ["email"]
liftIO $ print ("Redirecting", s)
redirectString RedirectTemporary s
return ()
getFacebookR = do
FB f <- getYesod
code <- runFormGet' $ stringInput "code"
at <- liftIO $ getAccessToken f $ pack code
at <- liftIO $ getAccessToken f code
mreq <- runFormGet' $ maybeStringInput "req"
let req = fromMaybe "me" mreq
Right so <- liftIO $ getGraphData at $ pack req
Right so <- liftIO $ getGraphData at req
let so' = objToHamlet so
hamletToRepHtml [$hamlet|\
<form>
<input type="hidden" name="code" value="#{string code}">
<input type="hidden" name="code" value="#{code}">
\Request:
<input type="text" name="req" value="#{string req}">
<input type="text" name="req" value="#{req}">
\
<input type="submit">
<hr>