Fix Xero token request
This commit is contained in:
parent
cce6811df2
commit
75a6896ec8
3 changed files with 14 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
14
src/Xero.hs
14
src/Xero.hs
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue