This commit is contained in:
patrick brisbin 2020-12-10 11:10:22 -05:00
parent 5d78b889b0
commit 8f532bcfa5
No known key found for this signature in database
GPG Key ID: 20299C6982D938FB
2 changed files with 9 additions and 6 deletions

View File

@ -22,7 +22,8 @@ module Yesod.Auth.OAuth2
, getRefreshToken
, getUserResponse
, getUserResponseJSON
) where
)
where
import Control.Error.Util (note)
import Control.Monad ((<=<))
@ -65,16 +66,14 @@ authOAuth2Widget widget name oauth getCreds =
-- | Read the @'AccessToken'@ from the values set via @'setExtra'@
getAccessToken :: Creds m -> Maybe AccessToken
getAccessToken =
(AccessToken <$>) . lookup "accessToken" . credsExtra
getAccessToken = (AccessToken <$>) . lookup "accessToken" . credsExtra
-- | Read the @'RefreshToken'@ from the values set via @'setExtra'@
--
-- N.B. not all providers supply this value.
--
getRefreshToken :: Creds m -> Maybe RefreshToken
getRefreshToken =
(RefreshToken <$>) . lookup "refreshToken" . credsExtra
getRefreshToken = (RefreshToken <$>) . lookup "refreshToken" . credsExtra
-- | Read the original profile response from the values set via @'setExtra'@
getUserResponse :: Creds m -> Maybe ByteString

View File

@ -63,7 +63,11 @@ dispatchForward name oauth2 = do
-- 2. Use the code parameter to fetch an AccessToken for the Provider
-- 3. Use the AccessToken to construct a @'Creds'@ value for the Provider
--
dispatchCallback :: Text -> OAuth2 -> FetchCreds m -> AuthHandler m TypedContent
dispatchCallback
:: Text
-> OAuth2
-> FetchCreds m
-> AuthHandler m TypedContent
dispatchCallback name oauth2 getCreds = do
csrf <- verifySessionCSRF $ tokenSessionKey name
onErrorResponse $ oauth2HandshakeError name