azure-maps-leaflet
azure-maps-leaflet copied to clipboard
Expired anonymous token handling error "Token Expired, Try again"
Please provide us with the following information:
This issue is for a: (mark with an x)
- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)
Minimal steps to reproduce
- Anonymous auth method, retrieve map access token from Azure Maps via App Service and System Managed Identity.
- Put tab in background.
- Wait for token to be expired ~24hrs?.
- Move map and request for tiles.
Any log messages given by the failure
Error: "Token Expired, Try again"
Expected/desired behavior
Should handle an expired token rather than throwing an exception.
OS and Version?
Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)
- macOS 14.1
- MS Edge 118.0.2088.76
Versions
Mention any other details that might be useful
AAD might still give out a valid token (with 5 seconds left of validity) which could expire by the time the front end receives it. We cannot control or force a fresh token from AAD so expired tokens should be handled by the map library instead - auto retry or whatever rather than just throwing exception.
See problem line where it gives up: https://github.com/Azure-Samples/azure-maps-leaflet/blob/7d9786a050549e440ddb78252949689f03215574/src/internal/AuthenticationManager.ts#L264
Thanks! We'll be in touch soon.
I've also noticed this line https://github.com/Azure-Samples/azure-maps-leaflet/blob/7d9786a050549e440ddb78252949689f03215574/src/internal/AuthenticationManager.ts#L253 which seems to be providing the old token as it's in "local storage" and not cleared at end of session.