From de589f8cb64b4df80172fedb51a0f8b0a97184b7 Mon Sep 17 00:00:00 2001 From: Brian Schroeder Date: Thu, 27 Jul 2017 23:36:09 -0400 Subject: [PATCH] Update Nylas provider - Nylas now requires additional parameters for authentication to succeed - We remove oauth2NylasScoped because it wasn't exported, and Nylas does not support any scopes other than "email" --- Yesod/Auth/OAuth2/Nylas.hs | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/Yesod/Auth/OAuth2/Nylas.hs b/Yesod/Auth/OAuth2/Nylas.hs index 57e470f..cf4e5d3 100644 --- a/Yesod/Auth/OAuth2/Nylas.hs +++ b/Yesod/Auth/OAuth2/Nylas.hs @@ -23,8 +23,6 @@ import Yesod.Auth (Creds(..), YesodAuth, AuthPlugin) import Yesod.Auth.OAuth2 (OAuth2(..), AccessToken(..) , YesodOAuth2Exception(InvalidProfileResponse) , authOAuth2) - -import qualified Data.Text as T import qualified Network.HTTP.Types as HT data NylasAccount = NylasAccount @@ -48,25 +46,16 @@ oauth2Nylas :: YesodAuth m => Text -- ^ Client ID -> Text -- ^ Client Secret -> AuthPlugin m -oauth2Nylas = oauth2NylasScoped ["email"] - -oauth2NylasScoped :: YesodAuth m - => [Text] -- ^ Scopes - -> Text -- ^ Client ID - -> Text -- ^ Client Secret - -> AuthPlugin m -oauth2NylasScoped scopes clientId clientSecret = - authOAuth2 "nylas" oauth fetchCreds +oauth2Nylas clientId clientSecret = authOAuth2 "nylas" oauth fetchCreds where - authorizeUrl = encodeUtf8 - $ "https://api.nylas.com/oauth/authorize?scope=" - <> T.intercalate "," scopes - tokenUrl = "https://api.nylas.com/oauth/token" + authorizeUrl = encodeUtf8 $ "https://api.nylas.com/oauth/authorize" <> + "?response_type=code&scope=email&client_id=" <> clientId + oauth = OAuth2 { oauthClientId = encodeUtf8 clientId , oauthClientSecret = encodeUtf8 clientSecret , oauthOAuthorizeEndpoint = authorizeUrl - , oauthAccessTokenEndpoint = tokenUrl + , oauthAccessTokenEndpoint = "https://api.nylas.com/oauth/token" , oauthCallback = Nothing }