Nswag: Retry Request after unauthorized Response (Typescript client)

Created on 27 Aug 2018  路  2Comments  路  Source: RicoSuter/NSwag

I would like to intercept the Response if it has status 401, then use a RefreshToken to fetch a new AccessToken and then update the local user details and then retry the original request.

So I have set up the BaseClient with transformOptions and transformResult, in transformOptions I add the auth header to the request. And in transformResult I'm checking the result for 401, here I would like to refresh the access token and then send the original request again, but transformResult only gives the following parameters:
transformResult(url: string, response: Response, processor: (response: Response) => Promise<any>): Promise<any>

Please advise if this is possible and if you know a way to add this functionality to the client generated code. Thanks

NSwag.CodeGeneration.TypeScript question

Most helpful comment

Looking into doing the exact same thing :)

All 2 comments

Looking into doing the exact same thing :)

Does anyone have a nice solution for this?

Was this page helpful?
0 / 5 - 0 ratings