mirror of
https://github.com/freckle/yesod-auth-oauth2.git
synced 2026-09-07 18:33:50 +02: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)
|
## [*Unreleased*](https://github.com/thoughtbot/yesod-auth-oauth2/compare/v0.6.1.2...master)
|
||||||
|
|
||||||
- Add WordPress.com provider
|
- 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)
|
## [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 #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
module Yesod.Auth.OAuth2.WordPressDotCom where
|
module Yesod.Auth.OAuth2.WordPressDotCom
|
||||||
|
( oauth2WordPressDotCom
|
||||||
|
)
|
||||||
|
where
|
||||||
|
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import Yesod.Auth.OAuth2.Prelude
|
import Yesod.Auth.OAuth2.Prelude
|
||||||
@ -11,19 +14,20 @@ pluginName = "WordPress.com"
|
|||||||
newtype WpUser = WpUser Int
|
newtype WpUser = WpUser Int
|
||||||
|
|
||||||
instance FromJSON WpUser where
|
instance FromJSON WpUser where
|
||||||
parseJSON = withObject "WpUser" $ \o -> WpUser
|
parseJSON = withObject "WpUser" $ \o -> WpUser <$> o .: "ID"
|
||||||
<$> o .: "ID"
|
|
||||||
|
|
||||||
oauth2WordPressDotCom
|
oauth2WordPressDotCom
|
||||||
:: ( YesodAuth m )
|
:: (YesodAuth m)
|
||||||
=> Text -- client ID
|
=> Text -- ^ Client Id
|
||||||
-> Text -- client secret
|
-> Text -- ^ Client Secret
|
||||||
-> AuthPlugin m
|
-> AuthPlugin m
|
||||||
oauth2WordPressDotCom clientId clientSecret =
|
oauth2WordPressDotCom clientId clientSecret =
|
||||||
authOAuth2 pluginName oauth2 $ \manager token -> do
|
authOAuth2 pluginName oauth2 $ \manager token -> do
|
||||||
(WpUser userId, userResponse) <-
|
(WpUser userId, userResponse) <- authGetProfile
|
||||||
authGetProfile pluginName manager token
|
pluginName
|
||||||
"https://public-api.wordpress.com/rest/v1/me/"
|
manager
|
||||||
|
token
|
||||||
|
"https://public-api.wordpress.com/rest/v1/me/"
|
||||||
|
|
||||||
pure Creds
|
pure Creds
|
||||||
{ credsPlugin = pluginName
|
{ credsPlugin = pluginName
|
||||||
@ -37,7 +41,7 @@ oauth2WordPressDotCom clientId clientSecret =
|
|||||||
, oauthClientSecret = clientSecret
|
, oauthClientSecret = clientSecret
|
||||||
, oauthOAuthorizeEndpoint =
|
, oauthOAuthorizeEndpoint =
|
||||||
"https://public-api.wordpress.com/oauth2/authorize"
|
"https://public-api.wordpress.com/oauth2/authorize"
|
||||||
`withQuery` [ scopeParam "," [ "auth" ] ]
|
`withQuery` [scopeParam "," ["auth"]]
|
||||||
, oauthAccessTokenEndpoint =
|
, oauthAccessTokenEndpoint =
|
||||||
"https://public-api.wordpress.com/oauth2/token"
|
"https://public-api.wordpress.com/oauth2/token"
|
||||||
, oauthCallback = Nothing
|
, oauthCallback = Nothing
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user