mirror of
https://github.com/freckle/yesod-auth-oauth2.git
synced 2026-09-02 01:43:51 +02:00
Remove Twitter module
- Twitter does not support OAuth 2[1] The motivating issue was created without realizing this (it is a bit surprising), and the module that was committed doesn't appear to work. - For OAuth 1, support[2] already exists Fixes #25 [1]: https://twittercommunity.com/t/oauth-2-0-support/253 [2]: http://hackage.haskell.org/package/yesod-auth-oauth-1.4.0.2/docs/Yesod-Auth-OAuth.html
This commit is contained in:
parent
631d9a3ca1
commit
29b4a7f4e7
@ -1,53 +0,0 @@
|
|||||||
{-# LANGUAGE CPP #-}
|
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
|
||||||
module Yesod.Auth.OAuth2.Twitter
|
|
||||||
( oauth2Twitter
|
|
||||||
, module Yesod.Auth.OAuth2
|
|
||||||
) where
|
|
||||||
|
|
||||||
#if __GLASGOW_HASKELL__ < 710
|
|
||||||
import Control.Applicative ((<$>), (<*>))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
import Control.Monad (mzero)
|
|
||||||
import Data.Aeson
|
|
||||||
import Data.Text (Text)
|
|
||||||
import Data.Text.Encoding (encodeUtf8)
|
|
||||||
import Yesod.Auth
|
|
||||||
import Yesod.Auth.OAuth2
|
|
||||||
|
|
||||||
data TwitterUser = TwitterUser
|
|
||||||
{ twitterUserId :: Text
|
|
||||||
, twitterUserName :: Text
|
|
||||||
, twitterScreenName :: Text
|
|
||||||
}
|
|
||||||
|
|
||||||
instance FromJSON TwitterUser where
|
|
||||||
parseJSON (Object o) = TwitterUser
|
|
||||||
<$> o .: "id_str"
|
|
||||||
<*> o .: "name"
|
|
||||||
<*> o .: "screen_name"
|
|
||||||
|
|
||||||
parseJSON _ = mzero
|
|
||||||
|
|
||||||
oauth2Twitter :: YesodAuth m
|
|
||||||
=> Text -- ^ Client ID
|
|
||||||
-> Text -- ^ Client Secret
|
|
||||||
-> AuthPlugin m
|
|
||||||
oauth2Twitter clientId clientSecret = authOAuth2 "twitter"
|
|
||||||
OAuth2
|
|
||||||
{ oauthClientId = encodeUtf8 clientId
|
|
||||||
, oauthClientSecret = encodeUtf8 clientSecret
|
|
||||||
, oauthOAuthorizeEndpoint = "https://api.twitter.com/oauth/authorize"
|
|
||||||
, oauthAccessTokenEndpoint = "https://api.twitter.com/oauth/access_token"
|
|
||||||
, oauthCallback = Nothing
|
|
||||||
}
|
|
||||||
$ fromProfileURL "twitter" "https://api.twitter.com/1.1/account/verify_credentials.json"
|
|
||||||
$ \user -> Creds
|
|
||||||
{ credsPlugin = "twitter"
|
|
||||||
, credsIdent = twitterUserId user
|
|
||||||
, credsExtra =
|
|
||||||
[ ("name", twitterUserName user)
|
|
||||||
, ("screen_name", twitterScreenName user)
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@ -43,7 +43,6 @@ library
|
|||||||
Yesod.Auth.OAuth2.Github
|
Yesod.Auth.OAuth2.Github
|
||||||
Yesod.Auth.OAuth2.Google
|
Yesod.Auth.OAuth2.Google
|
||||||
Yesod.Auth.OAuth2.Spotify
|
Yesod.Auth.OAuth2.Spotify
|
||||||
Yesod.Auth.OAuth2.Twitter
|
|
||||||
Yesod.Auth.OAuth2.Upcase
|
Yesod.Auth.OAuth2.Upcase
|
||||||
Yesod.Auth.OAuth2.EveOnline
|
Yesod.Auth.OAuth2.EveOnline
|
||||||
Yesod.Auth.OAuth2.Nylas
|
Yesod.Auth.OAuth2.Nylas
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user