Sample of token expiration handling
See original GitHub issueFeature Request
Is your feature request related to a problem? Please describe.
It is not clear how to handle tokens after they expires. All the samples in this repo call the token API once and not handling token expiration.
Currently, I handle the token expiration on my own - when the token is about to expire, I get a refreshed token use createDirectLine({ token })
with the new token. I’m not sure if this the desired approach. Since I believe that the directline should be created once (the current conversation will be interrupted)
Describe the suggestion or request in detail
Please add a sample to this repo of how to handle token expiration.
Describe alternatives you have considered
Additional context
[feature-request]
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Configure Refresh Token Expiration - Auth0
Learn how to configure the refresh token expiration lifetimes. ... Here is an example that sets expiration lifetime for a non-rotating refresh token:....
Read more >Handling Access Token Expiration - Oracle Help Center
Using an expired JWT will cause operations to fail. As you saw above, we are told how long a token is valid through...
Read more >Managing JWT token expiration - Medium
Check if the token has expired. If the token is expired we clean up the existing token, application state and redirect the user...
Read more >Handling Expired Access Tokens | MuleSoft Documentation
Most services providers return (or should return) access tokens with a limited lifespan. In general, access tokens usually expire about 30 to 60...
Read more >Specify the maximum token expiration time—Portal for ArcGIS
A token with a longer expiration time is less secure. For example, a token intercepted by a malicious user can be used until...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@hraz-msft, I suspect the issue is how you are introducing the refreshed token into your Web Chat component. In the example I provide below, I am able to refresh the token while maintaining the conversation context without issue.
In short, I get my initial token and pass it into a function,
createDirectLine
, to create a Direct Line object with it. The output of this is passed intostartWebChat
which initiatesrenderWebChat
. Lastly, I have a function,conversationTimer
, which is called immediately to start the countdown.When the countdown is completed, a refreshed token is acquired,
createDirectLine
is called again with the refreshed token passed into it followed by callingstartWebChat
once more which reconnects the Web Chat component using the new token. Then the countdown/process begins, again.FYI, I use locally hosted endpoints for calling a “token server” where I exchange my Direct Line secret for a token. I also set the timer to just 15 secs for effect.
Thanks @stevkan for this sample! I think I’ve found the issue on our side. I’m closing the issue now, and I will re-open it again and tag you if other issues will come up due to the refresh