mirror of
https://github.com/freckle/yesod-auth-oauth2.git
synced 2026-01-12 04:08:30 +01:00
Switch to new, safer URL parsing function
This commit is contained in:
parent
de589f8cb6
commit
dc70ce8048
@ -16,13 +16,13 @@ import Data.Aeson (FromJSON, Value(..), parseJSON, decode, (.:))
|
||||
import Data.Monoid ((<>))
|
||||
import Data.Text (Text)
|
||||
import Data.Text.Encoding (encodeUtf8, decodeUtf8)
|
||||
import Network.HTTP.Client (applyBasicAuth, parseUrl, httpLbs, responseStatus
|
||||
, responseBody)
|
||||
import Network.HTTP.Client (applyBasicAuth, httpLbs, parseRequest, responseBody,
|
||||
responseStatus)
|
||||
import Network.HTTP.Conduit (Manager)
|
||||
import Yesod.Auth (Creds(..), YesodAuth, AuthPlugin)
|
||||
import Yesod.Auth.OAuth2 (OAuth2(..), AccessToken(..)
|
||||
, YesodOAuth2Exception(InvalidProfileResponse)
|
||||
, authOAuth2)
|
||||
import Yesod.Auth.OAuth2 (OAuth2(..), AccessToken(..),
|
||||
YesodOAuth2Exception(InvalidProfileResponse),
|
||||
authOAuth2)
|
||||
import qualified Network.HTTP.Types as HT
|
||||
|
||||
data NylasAccount = NylasAccount
|
||||
@ -61,7 +61,7 @@ oauth2Nylas clientId clientSecret = authOAuth2 "nylas" oauth fetchCreds
|
||||
|
||||
fetchCreds :: Manager -> AccessToken -> IO (Creds a)
|
||||
fetchCreds manager token = do
|
||||
req <- authorize <$> parseUrl "https://api.nylas.com/account"
|
||||
req <- authorize <$> parseRequest "https://api.nylas.com/account"
|
||||
resp <- httpLbs req manager
|
||||
if HT.statusIsSuccessful (responseStatus resp)
|
||||
then case decode (responseBody resp) of
|
||||
|
||||
Loading…
Reference in New Issue
Block a user