Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refreshToken called multiple times #135

Open
heshesh2010 opened this issue Aug 27, 2023 · 2 comments
Open

refreshToken called multiple times #135

heshesh2010 opened this issue Aug 27, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@heshesh2010
Copy link

heshesh2010 commented Aug 27, 2023

Hi ,

I call many api at same time , but I see when token expire I got 401 , so it's goes to refresh token and retry , but in the same time the other api request in queue gets called and try to refresh the token again , so refresh api return 422 error . so it should only calling only once .

so how to pause the all other apis request until the token it gets refreshed ?

using http_interceptor: ^2.0.0-beta.7

`

  @override
  Future<bool> shouldAttemptRetryOnResponse(BaseResponse response) async {
    if (response.statusCode == 401) {
      print('Retrying request...');
      // final cache = await SharedPreferences.getInstance();

      // cache.setString(kOWApiToken, kOpenWeatherApiKey);

      AuthController authController = Get.put(AuthController());
      authController.refreshToken();

      return true;
    }

    return false;
  }

`

@heshesh2010 heshesh2010 added the bug Something isn't working label Aug 27, 2023
@PKeviin
Copy link

PKeviin commented Nov 21, 2023

Hi, this PR #96 seems to solve your problem.
Unfortunately, it does not seem to be abandoned.

@ChoyCheeWei
Copy link

any updates on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants