question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

refresh token logic got loop back to createRequestQueueInterceptor

See original GitHub issue

Problem: refresh token axios got loop back to createRequestQueueInterceptor, refreshing becomes stale

Hi~ thanks for the lib. Summary: I have the same default axios running for normal request and refresh token, when it wants to run the refresh token, the request got queue to requestQueue, so it ended up stale. and the refreshing is never resolve.

Here are the usage:

// Instantiate the interceptor (you can chain it as it returns the axios instance)
createAuthRefreshInterceptor(axios, refreshAuthLogic);

const refreshAuthLogic = (failedRequest: any) => {
  const asyncToPromise = async () => {
    // ...preprocessing
    const resp = await axios.post('/refreshUrl')
    const {accessToken} = resp.data
  // ...postprocessing
    return Promise.resolve(accessToken)
  }

  return asyncToPromise().then(async accessToken => {
    failedRequest.response.config.headers['Authorization'] = 'Bearer ' + accessToken;
    return Promise.resolve();
  })
};

Current workaround: create another axios instance just for refreshing, so it wont get intercept

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:24 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
PhilippeCollincommented, Oct 23, 2020

Isn’t the skipAuthRefresh flag supposed to be passed in the request config? When using axios.post, that would be the third argument (and not the second) if I’m not mistaken.

1reaction
Flyrellcommented, Sep 16, 2021

Merged in #163 with a fix in #166. Thanks for the contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

feat(authentication): refreshing/replacing the token · Issue #4573
The simplest approach: very long-lived access token with no refresh mechanism. This means creating access tokens with TTL set to weeks or months ......
Read more >
JWT Authentication Extension | LoopBack Documentation
@loopback/authentication-jwt · To generate refresh token : to generate the refresh token and access token when user logins to your app with provided...
Read more >
Refresh AccessToken in Loopback 3 - node.js - Stack Overflow
Just update created field in accessToken table against a particular user. Go to server.js file and update the following code :
Read more >
Cisco Secure Firewall ASA Series Syslog Messages - Cisco
Flow is a loopback. Free the flow created as result of packet injection. The connection was built because the packet tracer feature sent...
Read more >
Component Reference - Apache JMeter - User's Manual
Several test elements use JMeter properties to control their behaviour. These properties are normally resolved when the class is loaded.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found