mirror of
https://github.com/freckle/yesod-auth-oauth2.git
synced 2026-03-31 00:59:47 +02: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.Monoid ((<>))
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import Data.Text.Encoding (encodeUtf8, decodeUtf8)
|
import Data.Text.Encoding (encodeUtf8, decodeUtf8)
|
||||||
import Network.HTTP.Client (applyBasicAuth, parseUrl, httpLbs, responseStatus
|
import Network.HTTP.Client (applyBasicAuth, httpLbs, parseRequest, responseBody,
|
||||||
, responseBody)
|
responseStatus)
|
||||||
import Network.HTTP.Conduit (Manager)
|
import Network.HTTP.Conduit (Manager)
|
||||||
import Yesod.Auth (Creds(..), YesodAuth, AuthPlugin)
|
import Yesod.Auth (Creds(..), YesodAuth, AuthPlugin)
|
||||||
import Yesod.Auth.OAuth2 (OAuth2(..), AccessToken(..)
|
import Yesod.Auth.OAuth2 (OAuth2(..), AccessToken(..),
|
||||||
, YesodOAuth2Exception(InvalidProfileResponse)
|
YesodOAuth2Exception(InvalidProfileResponse),
|
||||||
, authOAuth2)
|
authOAuth2)
|
||||||
import qualified Network.HTTP.Types as HT
|
import qualified Network.HTTP.Types as HT
|
||||||
|
|
||||||
data NylasAccount = NylasAccount
|
data NylasAccount = NylasAccount
|
||||||
@ -61,7 +61,7 @@ oauth2Nylas clientId clientSecret = authOAuth2 "nylas" oauth fetchCreds
|
|||||||
|
|
||||||
fetchCreds :: Manager -> AccessToken -> IO (Creds a)
|
fetchCreds :: Manager -> AccessToken -> IO (Creds a)
|
||||||
fetchCreds manager token = do
|
fetchCreds manager token = do
|
||||||
req <- authorize <$> parseUrl "https://api.nylas.com/account"
|
req <- authorize <$> parseRequest "https://api.nylas.com/account"
|
||||||
resp <- httpLbs req manager
|
resp <- httpLbs req manager
|
||||||
if HT.statusIsSuccessful (responseStatus resp)
|
if HT.statusIsSuccessful (responseStatus resp)
|
||||||
then case decode (responseBody resp) of
|
then case decode (responseBody resp) of
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user