Fix Xero token request

This commit is contained in:
Rene Vergara 2023-03-15 15:52:52 -05:00
parent cce6811df2
commit 75a6896ec8
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2
3 changed files with 14 additions and 6 deletions

View file

@ -20,6 +20,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Separate periodic tasks from API server
- Zcash transaction monitoring changed to use memo parser
### Fixed
- Xero token generation for brand new users
## [1.2.5] - 2023-02-01
### Fixed

View file

@ -30,6 +30,6 @@ main = do
then do
let t = map (cast' . Doc) tokens
case creds of
Just c -> mapM_ (refreshToken pipe db c "") t
Just c -> mapM_ (refreshToken pipe db c "" "") t
Nothing -> fail "No credentials"
else putStrLn "No tokens to refresh1"

View file

@ -290,10 +290,11 @@ requestXeroToken :: Pipe -> T.Text -> Xero -> T.Text -> T.Text -> IO Bool
requestXeroToken pipe dbName cred code address = do
token <- access pipe master dbName $ findToken address
let oToken = token >>= cast' . Doc
refreshToken pipe dbName cred code oToken
refreshToken pipe dbName cred code address oToken
refreshToken :: Pipe -> T.Text -> Xero -> T.Text -> Maybe XeroToken -> IO Bool
refreshToken pipe dbName cred code token = do
refreshToken ::
Pipe -> T.Text -> Xero -> T.Text -> T.Text -> Maybe XeroToken -> IO Bool
refreshToken pipe dbName cred code address token = do
let pars =
case token of
Just x -> "grant_type=refresh_token&refresh_token=" <> t_refresh x
@ -316,9 +317,12 @@ refreshToken pipe dbName cred code token = do
200 -> do
let newToken = getResponseBody (res :: Response XeroToken)
let accCode = t_code <$> token
let address = t_address <$> token
{-let address = t_address <$> token-}
pToken <-
processToken newToken (fromMaybe "" address) (fromMaybe "" accCode)
processToken
newToken
(maybe address t_address token)
(fromMaybe "" accCode)
--print pToken
_ <- access pipe master dbName $ upsertToken pToken
_ <- getTenantId pipe dbName pToken