mirror of
https://github.com/freckle/yesod-auth-oauth2.git
synced 2026-01-11 19:58:28 +01:00
Cleanup WordPress plugin
- Explicit exports - Fixup Haddock formatting - Brittany & Stylish - CHANGELOG attribution
This commit is contained in:
parent
40119bd1f3
commit
60c0f68d5a
@ -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)
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user