diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b8bb31..7b6d4ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## [*Unreleased*](https://github.com/thoughtbot/yesod-auth-oauth2/compare/v0.6.1.2...master) - Add WordPress.com provider + [@nbloomf](https://github.com/thoughtbot/yesod-auth-oauth2/pull/130) ## [v0.6.1.2](https://github.com/thoughtbot/yesod-auth-oauth2/compare/v0.6.1.1...v0.6.1.2) diff --git a/src/Yesod/Auth/OAuth2/WordPressDotCom.hs b/src/Yesod/Auth/OAuth2/WordPressDotCom.hs index b953c5f..1b2ef5b 100644 --- a/src/Yesod/Auth/OAuth2/WordPressDotCom.hs +++ b/src/Yesod/Auth/OAuth2/WordPressDotCom.hs @@ -1,6 +1,9 @@ {-# LANGUAGE OverloadedStrings #-} -module Yesod.Auth.OAuth2.WordPressDotCom where +module Yesod.Auth.OAuth2.WordPressDotCom + ( oauth2WordPressDotCom + ) +where import qualified Data.Text as T import Yesod.Auth.OAuth2.Prelude @@ -11,19 +14,20 @@ pluginName = "WordPress.com" newtype WpUser = WpUser Int instance FromJSON WpUser where - parseJSON = withObject "WpUser" $ \o -> WpUser - <$> o .: "ID" + parseJSON = withObject "WpUser" $ \o -> WpUser <$> o .: "ID" oauth2WordPressDotCom - :: ( YesodAuth m ) - => Text -- client ID - -> Text -- client secret + :: (YesodAuth m) + => Text -- ^ Client Id + -> Text -- ^ Client Secret -> AuthPlugin m oauth2WordPressDotCom clientId clientSecret = authOAuth2 pluginName oauth2 $ \manager token -> do - (WpUser userId, userResponse) <- - authGetProfile pluginName manager token - "https://public-api.wordpress.com/rest/v1/me/" + (WpUser userId, userResponse) <- authGetProfile + pluginName + manager + token + "https://public-api.wordpress.com/rest/v1/me/" pure Creds { credsPlugin = pluginName @@ -37,7 +41,7 @@ oauth2WordPressDotCom clientId clientSecret = , oauthClientSecret = clientSecret , oauthOAuthorizeEndpoint = "https://public-api.wordpress.com/oauth2/authorize" - `withQuery` [ scopeParam "," [ "auth" ] ] + `withQuery` [scopeParam "," ["auth"]] , oauthAccessTokenEndpoint = "https://public-api.wordpress.com/oauth2/token" , oauthCallback = Nothing