on master help sign in
Made it compile
commit0bede85ab53eb8f953cf6f4e58a756a205e88e0b authoriko <ilyakooo0@gmail.com> dateSat 4 Jan 2020, 16:20 (7 years ago) parent1ac3261
5 files changed+16−9
.gitignore+2 package.yaml+1 src/GitHub/App/Auth.hs+4−4 src/GitHub/App/Request.hs+4−2 stack.yaml+5−3
.gitignore+2
@@ -4,3 +4,5 @@ cabal.project.local
44cabal.project.local~
55.ghc.environment.*
66*.cabal
7+
8+.stack-work
package.yaml+1
@@ -48,6 +48,7 @@ library:
4848 - jwt >= 0.8.0
4949 - mtl
5050 - safe-exceptions
51+ - tagged
5152 - text
5253 - time
5354 - x509
src/GitHub/App/Auth.hs+4−4
@@ -27,6 +27,7 @@ import qualified Data.ByteString.Lazy as LBS
2727import Data.Functor (($>))
2828import Data.Maybe (fromMaybe)
2929import Data.Semigroup ((<>))
30+import Data.Tagged
3031import Data.Text (Text)
3132import qualified Data.Text as T
3233import Data.Text.Encoding (encodeUtf8)
@@ -37,8 +38,7 @@ import GitHub.Data.Apps (App)
3738import GitHub.Data.Definitions (Error (HTTPError))
3839import GitHub.Data.Id (Id, untagId)
3940import GitHub.Data.Installations (Installation)
40−import GitHub.Data.Request (StatusMap)
41−import GitHub.Request (parseResponse)
41+import GitHub.Request (StatusMap, parseResponseJSON)
4242import Network.HTTP.Client as HTTP
4343import qualified Network.HTTP.Client.Internal as HTTP
4444import qualified Network.HTTP.Types as HTTP
@@ -113,7 +113,7 @@ createAccessTokenR InstallationAuth{..} = do
113113 { iat = Just $ toJsonTime currentTime
114114 , exp = Just $ toJsonTime expiryTime
115115 }
116− jwt = encodeSigned (RSAPrivateKey iaAppPrivateKey) claims
116+ jwt = encodeSigned (RSAPrivateKey iaAppPrivateKey) mempty claims
117117
118118 req <- HTTP.parseRequest . T.unpack $ url
119119 pure req
@@ -148,7 +148,7 @@ obtainAccessToken mgr ia@InstallationAuth{..} = readMVar iaToken >>= \case
148148 renew :: IO (Either Error Auth)
149149 renew = bracketOnError (takeMVar iaToken) (putMVar iaToken) $ \_ -> do
150150 req <- createAccessTokenR ia
151− result <- runExceptT $ httpLbs' req >>= parseResponse
151+ result <- runExceptT $ httpLbs' req >>= parseResponseJSON
152152 case result of
153153 Right newToken -> putMVar iaToken (Just newToken) $> Right (itToken newToken)
154154 Left err -> putMVar iaToken Nothing $> Left err
src/GitHub/App/Request.hs+4−2
@@ -10,6 +10,7 @@ module GitHub.App.Request
1010 , executeAppRequestWithMgr
1111 ) where
1212
13+import Data.Aeson (FromJSON)
1314import GitHub.Data (Error (..))
1415import GitHub.Data.Request (Request)
1516import GitHub.Request (executeRequestWithMgr)
@@ -19,7 +20,7 @@ import Network.HTTP.Client.TLS (newTlsManager)
1920import GitHub.App.Auth (InstallationAuth, obtainAccessToken)
2021
2122
22−executeAppRequest :: InstallationAuth -> Request k a -> IO (Either Error a)
23+executeAppRequest :: FromJSON a => InstallationAuth -> Request k a -> IO (Either Error a)
2324executeAppRequest instAuth req = do
2425 manager <- newTlsManager
2526 x <- executeAppRequestWithMgr manager instAuth req
@@ -29,7 +30,8 @@ executeAppRequest instAuth req = do
2930 pure x
3031
3132executeAppRequestWithMgr
32− :: Manager
33+ :: FromJSON a
34+ => Manager
3335 -> InstallationAuth
3436 -> Request k a
3537 -> IO (Either Error a)
stack.yaml+5−3
@@ -1,9 +1,11 @@
1−resolver: lts-11.5
1+resolver: lts-14.19
22
33packages:
44- .
55# Dependency packages to be pulled from upstream that are not in the resolver
66# using the same syntax as the packages field.
77# (e.g., acme-missiles-0.3)
8−extra-deps:
9− - jwt-0.8.0
8+extra-deps:
9+ - github-0.24
10+ - binary-instances-1
11+ # - jwt-0.8.0