fix(api): handling expired token responses (#2113)
This commit is contained in:
@@ -115,7 +115,7 @@ export class HttpService implements HttpServiceInterface {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = (await this.post(joinPaths(this.host, Paths.v1.refreshSession), {
|
const response = (await this.post(Paths.v1.refreshSession, {
|
||||||
access_token: this.session.accessToken.value,
|
access_token: this.session.accessToken.value,
|
||||||
refresh_token: this.session.refreshToken.value,
|
refresh_token: this.session.refreshToken.value,
|
||||||
})) as SessionRefreshResponse
|
})) as SessionRefreshResponse
|
||||||
@@ -265,13 +265,12 @@ export class HttpService implements HttpServiceInterface {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
if (httpStatus >= HttpStatusCode.Success && httpStatus < HttpStatusCode.MultipleChoices) {
|
if (httpStatus >= HttpStatusCode.Success && httpStatus < HttpStatusCode.InternalServerError) {
|
||||||
resolve(response)
|
|
||||||
} else {
|
|
||||||
if (httpStatus === HttpStatusCode.Forbidden && response.data && response.data.error !== undefined) {
|
if (httpStatus === HttpStatusCode.Forbidden && response.data && response.data.error !== undefined) {
|
||||||
;(response.data as HttpErrorResponseBody).error.message = ErrorMessage.RateLimited
|
;(response.data as HttpErrorResponseBody).error.message = ErrorMessage.RateLimited
|
||||||
}
|
}
|
||||||
|
resolve(response)
|
||||||
|
} else {
|
||||||
reject(response)
|
reject(response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,4 +7,5 @@ export enum HttpStatusCode {
|
|||||||
Forbidden = 403,
|
Forbidden = 403,
|
||||||
Gone = 410,
|
Gone = 410,
|
||||||
ExpiredAccessToken = 498,
|
ExpiredAccessToken = 498,
|
||||||
|
InternalServerError = 500,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import * as Factory from './lib/factory.js'
|
|||||||
chai.use(chaiAsPromised)
|
chai.use(chaiAsPromised)
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
describe.skip('subscriptions', function () {
|
describe('subscriptions', function () {
|
||||||
this.timeout(Factory.TwentySecondTimeout)
|
this.timeout(Factory.TwentySecondTimeout)
|
||||||
|
|
||||||
let application
|
let application
|
||||||
|
|||||||
Reference in New Issue
Block a user