Skip to content

Commit d93f4dc

Browse files
committed
Clear authorization on 403 to fix outdated scope in trader
1 parent baafc6d commit d93f4dc

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/Classes/PoEAPI.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ function PoEAPIClass:ResetDetails()
6666
self.authToken = nil
6767
self.refreshToken = nil
6868
self.tokenExpiry = nil
69+
self:UpdateMain()
70+
end
71+
72+
--- updates main so that API details are saved across restarts
73+
function PoEAPIClass:UpdateMain()
74+
main.lastToken = self.authToken
75+
main.lastRefreshToken = self.refreshToken
76+
main.tokenExpiry = self.tokenExpiry
77+
main:SaveSettings()
6978
end
7079

7180
--- @param callback fun(errCode: string?)

src/Classes/TradeQuery.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,11 @@ function TradeQueryClass:UpdateRealms()
12131213
-- perform a generic search to make sure the authorization is valid.
12141214
self.tradeQueryRequests:PerformSearch("poe2", "Standard", [[{"query":{"status":{"option":"online"},"stats":[{"type":"and","filters":[]}]},"sort":{"price":"asc"}}]], function(response, errMsg)
12151215
if errMsg then
1216+
-- a 403 here likely means that the user has an outdated scope
1217+
if errMsg == "Response code: 403" then
1218+
main.api:ResetDetails()
1219+
errMsg = errMsg.."\nPlease re-authenticate"
1220+
end
12161221
self:SetNotice(self.controls.pbNotice, "Error: " .. tostring(errMsg))
12171222
end
12181223
end)

0 commit comments

Comments
 (0)