packages feed

hoauth2-tutorial 0.1.2 → 0.2

raw patch · 2 files changed

+25/−28 lines, 2 filesdep ~hoauth2PVP ok

version bump matches the API change (PVP)

Dependency ranges changed: hoauth2

API changes (from Hackage documentation)

- HOAuth2Tutorial: oauth2ErrorToText :: OAuth2Error Errors -> Text
+ HOAuth2Tutorial: oauth2ErrorToText :: TokenRequestError -> Text

Files

hoauth2-tutorial.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name:          hoauth2-tutorial-version:       0.1.2+version:       0.2 synopsis:      Tutorial for using hoauth2 description:   Tutorial to demostrate how to use hoauth2 to implement OAuth2 flow in an web Application.@@ -31,7 +31,7 @@     , aeson           >=2.0    && <2.2     , base            >=4.5    && <5     , bytestring      >=0.9    && <0.12-    , hoauth2         >=2.5+    , hoauth2         >=2.7     , http-conduit    >=2.1    && <2.4     , http-types      >=0.11   && <0.13     , scotty          >=0.10.0 && <0.13
src/HOAuth2Tutorial.hs view
@@ -118,19 +118,16 @@ import GHC.Generics (Generic) import Network.HTTP.Conduit (newManager, tlsManagerSettings) import Network.HTTP.Types (status302)-import Network.OAuth.OAuth2.AuthorizationRequest-  ( authorizationUrl,-  )-import Network.OAuth.OAuth2.HttpClient (authGetJSON)-import Network.OAuth.OAuth2.Internal-  ( ExchangeToken (ExchangeToken),-    OAuth2 (..),-    OAuth2Error,-    OAuth2Token (accessToken),-    appendQueryParams,-  )-import Network.OAuth.OAuth2.TokenRequest (fetchAccessToken)-import Network.OAuth.OAuth2.TokenRequest qualified as TR+import Network.OAuth.OAuth2 (+  ExchangeToken (ExchangeToken),+  OAuth2 (..),+  OAuth2Token (accessToken),+  TokenRequestError,+  appendQueryParams,+  authGetJSON,+  authorizationUrl,+  fetchAccessToken,+ ) import URI.ByteString (URI, serializeURIRef') import URI.ByteString.QQ (uri) import Web.Scotty (ActionM, scotty)@@ -145,18 +142,18 @@ auth0 :: OAuth2 auth0 =   OAuth2-    { oauth2ClientId = "TZlmNRtLY9duT8M4ztgFBLsFA66aEoGs",-      oauth2ClientSecret = "",-      oauth2AuthorizeEndpoint = [uri|https://freizl.auth0.com/authorize|],-      oauth2TokenEndpoint = [uri|https://freizl.auth0.com/oauth/token|],-      oauth2RedirectUri = [uri|http://localhost:9988/oauth2/callback|]+    { oauth2ClientId = "TZlmNRtLY9duT8M4ztgFBLsFA66aEoGs"+    , oauth2ClientSecret = ""+    , oauth2AuthorizeEndpoint = [uri|https://freizl.auth0.com/authorize|]+    , oauth2TokenEndpoint = [uri|https://freizl.auth0.com/oauth/token|]+    , oauth2RedirectUri = [uri|http://localhost:9988/oauth2/callback|]     }  authorizeUrl :: URI authorizeUrl =   appendQueryParams-    [ ("scope", "openid profile email"),-      ("state", randomStateValue)+    [ ("scope", "openid profile email")+    , ("state", randomStateValue)     ]     $ authorizationUrl auth0 @@ -172,9 +169,9 @@ -- | Auth0 user -- https://auth0.com/docs/api/authentication#get-user-info data Auth0User = Auth0User-  { name :: TL.Text,-    email :: TL.Text,-    sub :: TL.Text+  { name :: TL.Text+  , email :: TL.Text+  , sub :: TL.Text   }   deriving (Show, Generic) @@ -204,8 +201,8 @@    let info = case muser of         Just user ->-          [ "<p>Hello, " `TL.append` name user `TL.append` "</p>",-            "<a href='/logout'>Logout</a>"+          [ "<p>Hello, " `TL.append` name user `TL.append` "</p>"+          , "<a href='/logout'>Logout</a>"           ]         Nothing -> ["<a href='/login'>Login</a>"] @@ -286,5 +283,5 @@   result <- liftIO $ runExceptT e   either Scotty.raise pure result -oauth2ErrorToText :: OAuth2Error TR.Errors -> TL.Text+oauth2ErrorToText :: TokenRequestError -> TL.Text oauth2ErrorToText e = TL.pack $ "Unable fetch access token. error detail: " ++ show e