hoauth2 1.10.2 → 1.11.0
raw patch · 5 files changed
+55/−57 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Network.OAuth.OAuth2.Internal: OAuth2 :: Text -> Text -> URI -> URI -> Maybe URI -> OAuth2
+ Network.OAuth.OAuth2.Internal: OAuth2 :: Text -> Maybe Text -> URI -> URI -> Maybe URI -> OAuth2
- Network.OAuth.OAuth2.Internal: [oauthClientSecret] :: OAuth2 -> Text
+ Network.OAuth.OAuth2.Internal: [oauthClientSecret] :: OAuth2 -> Maybe Text
Files
- example/Keys.hs +35/−37
- example/Keys.hs.sample +11/−11
- hoauth2.cabal +1/−1
- src/Network/OAuth/OAuth2/HttpClient.hs +7/−7
- src/Network/OAuth/OAuth2/Internal.hs +1/−1
example/Keys.hs view
@@ -8,51 +8,50 @@ import URI.ByteString.QQ weiboKey :: OAuth2-weiboKey = OAuth2 { oauthClientId = "1962132691"- , oauthClientSecret = "a2ad30383bdff9bcb12be6a3d30deeb1"- , oauthCallback = Just [uri|http://127.0.0.1:9988/oauth2/callback|]- , oauthOAuthorizeEndpoint = [uri|https://api.weibo.com/oauth2/authorize|]- , oauthAccessTokenEndpoint = [uri|https://api.weibo.com/oauth2/access_token|]- }+weiboKey = OAuth2 { oauthClientId = "xxxxxxxxxxxxxxx"+ , oauthClientSecret = Just "xxxxxxxxxxxxxxxxxxxxxx"+ , oauthCallback = Just [uri|http://127.0.0.1:9988/oauthCallback|]+ , oauthOAuthorizeEndpoint = [uri|https://api.weibo.com/oauth2/authorize|]+ , oauthAccessTokenEndpoint = [uri|https://api.weibo.com/oauth2/access_token|]+ } -- | http://developer.github.com/v3/oauth/ githubKey :: OAuth2-githubKey = OAuth2 { oauthClientId = "bf86d338485a96a93c88"- , oauthClientSecret = "a1c00dada665dc00aa6fafe0495c7c885f82d1ce"- , oauthCallback = Just [uri|http://127.0.0.1:9988/oauth2/callback|]- , oauthOAuthorizeEndpoint = [uri|https://github.com/login/oauth/authorize|]- , oauthAccessTokenEndpoint = [uri|https://github.com/login/oauth/access_token|]- }+githubKey = OAuth2 { oauthClientId = "xxxxxxxxxxxxxxx"+ , oauthClientSecret = Just "xxxxxxxxxxxxxxxxxxxxxx"+ , oauthCallback = Just [uri|http://127.0.0.1:9988/githubCallback|]+ , oauthOAuthorizeEndpoint = [uri|https://github.com/login/oauth/authorize|]+ , oauthAccessTokenEndpoint = [uri|https://github.com/login/oauth/access_token|]+ } -- | oauthCallback = Just "https://developers.google.com/oauthplayground" googleKey :: OAuth2-googleKey = OAuth2 { oauthClientId = "886894027376.apps.googleusercontent.com"- , oauthClientSecret = "27w98gwGB1h8N5a6JQ2bT_nm"- , oauthCallback = Just [uri|http://127.0.0.1:9988/oauth2/callback|]+googleKey = OAuth2 { oauthClientId = "xxxxxxxxxxxxxxx.apps.googleusercontent.com"+ , oauthClientSecret = Just "xxxxxxxxxxxxxxxxxxxxxx"+ , oauthCallback = Just [uri|http://127.0.0.1:9988/googleCallback|] , oauthOAuthorizeEndpoint = [uri|https://accounts.google.com/o/oauth2/auth|] , oauthAccessTokenEndpoint = [uri|https://www.googleapis.com/oauth2/v3/token|] } - facebookKey :: OAuth2-facebookKey = OAuth2 { oauthClientId = "414630782030965"- , oauthClientSecret = "0e648eae100da4d03f16594f231fc1d0"- , oauthCallback = Just [uri|http://127.0.0.1:9988/oauth2/callback|]+facebookKey = OAuth2 { oauthClientId = "xxxxxxxxxxxxxxx"+ , oauthClientSecret = Just "xxxxxxxxxxxxxxxxxxxxxx"+ , oauthCallback = Just [uri|http://t.haskellcn.org/cb|] , oauthOAuthorizeEndpoint = [uri|https://www.facebook.com/dialog/oauth|] , oauthAccessTokenEndpoint = [uri|https://graph.facebook.com/v2.3/oauth/access_token|] } doubanKey :: OAuth2-doubanKey = OAuth2 { oauthClientId = "02a914cf299ca31607fb3e6d7cd5e942"- , oauthClientSecret = "3c0fdef13b0dd271"+doubanKey = OAuth2 { oauthClientId = "xxxxxxxxxxxxxxx"+ , oauthClientSecret = Just "xxxxxxxxxxxxxxxxxxxxxx" , oauthCallback = Just [uri|http://localhost:9999/oauthCallback|] , oauthOAuthorizeEndpoint = [uri|https://www.douban.com/service/auth2/auth|] , oauthAccessTokenEndpoint = [uri|https://www.douban.com/service/auth2/token|] } fitbitKey :: OAuth2-fitbitKey = OAuth2 { oauthClientId = "229LN9"- , oauthClientSecret = "2f4aa9a275c2d4bb9eb616efbd2c1311"+fitbitKey = OAuth2 { oauthClientId = "xxxxxx"+ , oauthClientSecret = Just "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" , oauthCallback = Just [uri|http://localhost:9988/oauth2/callback|] , oauthOAuthorizeEndpoint = [uri|https://www.fitbit.com/oauth2/authorize|] , oauthAccessTokenEndpoint = [uri|https://api.fitbit.com/oauth2/token|]@@ -64,24 +63,23 @@ stackexchangeAppKey = "xxxxxx" stackexchangeKey :: OAuth2-stackexchangeKey = OAuth2 { oauthClientId = "7185"- , oauthClientSecret = "K5hK)ET*dbFGFmNFVtqIyA(("+stackexchangeKey = OAuth2 { oauthClientId = "xx"+ , oauthClientSecret = Just "xxxxxxxxxxxxxxx" , oauthCallback = Just [uri|http://c.haskellcn.org/cb|] , oauthOAuthorizeEndpoint = [uri|https://stackexchange.com/oauth|] , oauthAccessTokenEndpoint = [uri|https://stackexchange.com/oauth/access_token|] }- dropboxKey :: OAuth2-dropboxKey = OAuth2 { oauthClientId = "zbyxxox19gz6dgg"- , oauthClientSecret = "ihhui0ysp85oi8s"+dropboxKey = OAuth2 { oauthClientId = "xxx"+ , oauthClientSecret = Just "xxx" , oauthCallback = Just [uri|http://localhost:9988/oauth2/callback|] , oauthOAuthorizeEndpoint = [uri|https://www.dropbox.com/1/oauth2/authorize|] , oauthAccessTokenEndpoint = [uri|https://api.dropboxapi.com/oauth2/token|] } oktaKey :: OAuth2-oktaKey = OAuth2 { oauthClientId = "0oad3popatwUIhWV40h7"- , oauthClientSecret = "x4ycjti9-bM-dw848U9MJO77wUcF-0ToBxk_61rF"+oktaKey = OAuth2 { oauthClientId = "xxx"+ , oauthClientSecret = Just "xxx" , oauthCallback = Just [uri|http://localhost:9988/oauth2/callback|] , oauthOAuthorizeEndpoint = [uri|https://dev-148986.oktapreview.com/oauth2/v1/authorize|] , oauthAccessTokenEndpoint = [uri|https://dev-148986.oktapreview.com/oauth2/v1/token|]@@ -89,16 +87,16 @@ azureADKey :: OAuth2 azureADKey = OAuth2 { oauthClientId = "xxx"- , oauthClientSecret = "xxx"+ , oauthClientSecret = Just "xxx" , oauthCallback = Just [uri|http://localhost:9988/oauth2/callback|] , oauthOAuthorizeEndpoint = [uri|https://login.windows.net/common/oauth2/authorize|] , oauthAccessTokenEndpoint = [uri|https://login.windows.net/common/oauth2/token|] } zohoKey :: OAuth2-zohoKey = OAuth2 { oauthClientId = "1000.U9JY0RDYUTMXCKKJFCCXL7V4QFCZ0H"- , oauthClientSecret = "b6088b1a88b967be647512a63d986e043210af35a0"- , oauthCallback = Just [uri|http://localhost:9988/oauth2/callback|]- , oauthOAuthorizeEndpoint = [uri|https://accounts.zoho.com/oauth/v2/auth|]- , oauthAccessTokenEndpoint = [uri|https://accounts.zoho.com/oauth/v2/token|]- }+zohoKey = OAuth2 { oauthClientId = "xxx"+ , oauthClientSecret = Just "xxx"+ , oauthCallback = Just [uri|http://localhost:9988/oauth2/callback|]+ , oauthOAuthorizeEndpoint = [uri|https://accounts.zoho.com/oauth/v2/auth|]+ , oauthAccessTokenEndpoint = [uri|https://accounts.zoho.com/oauth/v2/token|]+ }
example/Keys.hs.sample view
@@ -9,7 +9,7 @@ weiboKey :: OAuth2 weiboKey = OAuth2 { oauthClientId = "xxxxxxxxxxxxxxx"- , oauthClientSecret = "xxxxxxxxxxxxxxxxxxxxxx"+ , oauthClientSecret = Just "xxxxxxxxxxxxxxxxxxxxxx" , oauthCallback = Just [uri|http://127.0.0.1:9988/oauthCallback|] , oauthOAuthorizeEndpoint = [uri|https://api.weibo.com/oauth2/authorize|] , oauthAccessTokenEndpoint = [uri|https://api.weibo.com/oauth2/access_token|]@@ -18,7 +18,7 @@ -- | http://developer.github.com/v3/oauth/ githubKey :: OAuth2 githubKey = OAuth2 { oauthClientId = "xxxxxxxxxxxxxxx"- , oauthClientSecret = "xxxxxxxxxxxxxxxxxxxxxx"+ , oauthClientSecret = Just "xxxxxxxxxxxxxxxxxxxxxx" , oauthCallback = Just [uri|http://127.0.0.1:9988/githubCallback|] , oauthOAuthorizeEndpoint = [uri|https://github.com/login/oauth/authorize|] , oauthAccessTokenEndpoint = [uri|https://github.com/login/oauth/access_token|]@@ -27,7 +27,7 @@ -- | oauthCallback = Just "https://developers.google.com/oauthplayground" googleKey :: OAuth2 googleKey = OAuth2 { oauthClientId = "xxxxxxxxxxxxxxx.apps.googleusercontent.com"- , oauthClientSecret = "xxxxxxxxxxxxxxxxxxxxxx"+ , oauthClientSecret = Just "xxxxxxxxxxxxxxxxxxxxxx" , oauthCallback = Just [uri|http://127.0.0.1:9988/googleCallback|] , oauthOAuthorizeEndpoint = [uri|https://accounts.google.com/o/oauth2/auth|] , oauthAccessTokenEndpoint = [uri|https://www.googleapis.com/oauth2/v3/token|]@@ -35,7 +35,7 @@ facebookKey :: OAuth2 facebookKey = OAuth2 { oauthClientId = "xxxxxxxxxxxxxxx"- , oauthClientSecret = "xxxxxxxxxxxxxxxxxxxxxx"+ , oauthClientSecret = Just "xxxxxxxxxxxxxxxxxxxxxx" , oauthCallback = Just [uri|http://t.haskellcn.org/cb|] , oauthOAuthorizeEndpoint = [uri|https://www.facebook.com/dialog/oauth|] , oauthAccessTokenEndpoint = [uri|https://graph.facebook.com/v2.3/oauth/access_token|]@@ -43,7 +43,7 @@ doubanKey :: OAuth2 doubanKey = OAuth2 { oauthClientId = "xxxxxxxxxxxxxxx"- , oauthClientSecret = "xxxxxxxxxxxxxxxxxxxxxx"+ , oauthClientSecret = Just "xxxxxxxxxxxxxxxxxxxxxx" , oauthCallback = Just [uri|http://localhost:9999/oauthCallback|] , oauthOAuthorizeEndpoint = [uri|https://www.douban.com/service/auth2/auth|] , oauthAccessTokenEndpoint = [uri|https://www.douban.com/service/auth2/token|]@@ -51,7 +51,7 @@ fitbitKey :: OAuth2 fitbitKey = OAuth2 { oauthClientId = "xxxxxx"- , oauthClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"+ , oauthClientSecret = Just "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" , oauthCallback = Just [uri|http://localhost:9988/oauth2/callback|] , oauthOAuthorizeEndpoint = [uri|https://www.fitbit.com/oauth2/authorize|] , oauthAccessTokenEndpoint = [uri|https://api.fitbit.com/oauth2/token|]@@ -64,14 +64,14 @@ stackexchangeKey :: OAuth2 stackexchangeKey = OAuth2 { oauthClientId = "xx"- , oauthClientSecret = "xxxxxxxxxxxxxxx"+ , oauthClientSecret = Just "xxxxxxxxxxxxxxx" , oauthCallback = Just [uri|http://c.haskellcn.org/cb|] , oauthOAuthorizeEndpoint = [uri|https://stackexchange.com/oauth|] , oauthAccessTokenEndpoint = [uri|https://stackexchange.com/oauth/access_token|] } dropboxKey :: OAuth2 dropboxKey = OAuth2 { oauthClientId = "xxx"- , oauthClientSecret = "xxx"+ , oauthClientSecret = Just "xxx" , oauthCallback = Just [uri|http://localhost:9988/oauth2/callback|] , oauthOAuthorizeEndpoint = [uri|https://www.dropbox.com/1/oauth2/authorize|] , oauthAccessTokenEndpoint = [uri|https://api.dropboxapi.com/oauth2/token|]@@ -79,7 +79,7 @@ oktaKey :: OAuth2 oktaKey = OAuth2 { oauthClientId = "xxx"- , oauthClientSecret = "xxx"+ , oauthClientSecret = Just "xxx" , oauthCallback = Just [uri|http://localhost:9988/oauth2/callback|] , oauthOAuthorizeEndpoint = [uri|https://dev-148986.oktapreview.com/oauth2/v1/authorize|] , oauthAccessTokenEndpoint = [uri|https://dev-148986.oktapreview.com/oauth2/v1/token|]@@ -87,7 +87,7 @@ azureADKey :: OAuth2 azureADKey = OAuth2 { oauthClientId = "xxx"- , oauthClientSecret = "xxx"+ , oauthClientSecret = Just "xxx" , oauthCallback = Just [uri|http://localhost:9988/oauth2/callback|] , oauthOAuthorizeEndpoint = [uri|https://login.windows.net/common/oauth2/authorize|] , oauthAccessTokenEndpoint = [uri|https://login.windows.net/common/oauth2/token|]@@ -95,7 +95,7 @@ zohoKey :: OAuth2 zohoKey = OAuth2 { oauthClientId = "xxx"- , oauthClientSecret = "xxx"+ , oauthClientSecret = Just "xxx" , oauthCallback = Just [uri|http://localhost:9988/oauth2/callback|] , oauthOAuthorizeEndpoint = [uri|https://accounts.zoho.com/oauth/v2/auth|] , oauthAccessTokenEndpoint = [uri|https://accounts.zoho.com/oauth/v2/token|]
hoauth2.cabal view
@@ -1,7 +1,7 @@ Cabal-version: 2.4 Name: hoauth2 -- http://wiki.haskell.org/Package_versioning_policy-Version: 1.10.2+Version: 1.11.0 Synopsis: Haskell OAuth2 authentication client
src/Network/OAuth/OAuth2/HttpClient.hs view
@@ -63,9 +63,8 @@ -> IO (OAuth2Result TR.Errors OAuth2Token) -- ^ Access Token fetchAccessToken2 mgr oa code = do let (url, body1) = accessTokenUrl oa code- let extraBody = [ ("client_id", T.encodeUtf8 $ oauthClientId oa)- , ("client_secret", T.encodeUtf8 $ oauthClientSecret oa)- ]+ let secret x = [("client_secret", T.encodeUtf8 x)]+ let extraBody = ("client_id", T.encodeUtf8 $ oauthClientId oa) : maybe [] secret (oauthClientSecret oa) doJSONPostRequest mgr oa url (extraBody ++ body1) -- | Fetch a new AccessToken with the Refresh Token with authentication in request header.@@ -91,9 +90,8 @@ -> IO (OAuth2Result TR.Errors OAuth2Token) refreshAccessToken2 manager oa token = do let (uri, body) = refreshAccessTokenUrl oa token- let extraBody = [ ("client_id", T.encodeUtf8 $ oauthClientId oa)- , ("client_secret", T.encodeUtf8 $ oauthClientSecret oa)- ]+ let secret x = [("client_secret", T.encodeUtf8 x)]+ let extraBody = ("client_id", T.encodeUtf8 $ oauthClientId oa) : maybe [] secret (oauthClientSecret oa) doJSONPostRequest manager oa uri (extraBody ++ body) -- | Conduct post request and return response as JSON.@@ -114,7 +112,9 @@ doSimplePostRequest manager oa url body = fmap handleOAuth2TokenResponse go where go = do req <- uriToRequest url- let addBasicAuth = applyBasicAuth (T.encodeUtf8 $ oauthClientId oa) (T.encodeUtf8 $ oauthClientSecret oa)+ let addBasicAuth = case oauthClientSecret oa of+ (Just secret) -> applyBasicAuth (T.encodeUtf8 $ oauthClientId oa) (T.encodeUtf8 secret)+ Nothing -> id req' = (addBasicAuth . updateRequestHeaders Nothing) req httpLbs (urlEncodedBody body req') manager
src/Network/OAuth/OAuth2/Internal.hs view
@@ -37,7 +37,7 @@ -- | Query Parameter Representation data OAuth2 = OAuth2 { oauthClientId :: Text- , oauthClientSecret :: Text+ , oauthClientSecret :: Maybe Text , oauthOAuthorizeEndpoint :: URI , oauthAccessTokenEndpoint :: URI , oauthCallback :: Maybe URI