mirror of
https://github.com/freckle/yesod-auth-oauth2.git
synced 2026-01-28 03:40:25 +01:00
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"
This commit is contained in:
parent
e756d88e1b
commit
de589f8cb6
@ -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
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user