Azure Map Leaflet plugin token expired handling

Janrey Ocfemia 35 Reputation points
2023-11-28T00:14:27.8933333+00:00

I'm using the Azure Maps Leaflet plugin https://github.com/Azure-Samples/azure-maps-leaflet.

I've run into an issue when using "anonymous" authentication type eg. (https://learn.microsoft.com/en-us/azure/azure-maps/how-to-secure-spa-app). The issue occurs when the map token has expired and the user closes the tab then re-opens, they'll get an exception/error "Token Expired, Try again". It doesn't appear that azure-maps-leaftlet handles expired tokens. It seems to store the token in local storage but doesn't handle the expiry.

Does anyone know if azure-maps-leaflet will be able to support expired token handling in future?

Azure Maps
Azure Maps
An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.
654 questions
0 comments No comments
{count} vote

Accepted answer
  1. rbrundritt 16,456 Reputation points Microsoft Employee
    2023-11-28T17:44:25.7633333+00:00

    Checking the source code of the Azure Maps leaflet control there does appear to be code to handle token expiry when the map is reloaded and the token is retrieved from cache: https://github.com/Azure-Samples/azure-maps-leaflet/blob/7d9786a050549e440ddb78252949689f03215574/src/internal/AuthenticationManager.ts#L259

    That said, I think there may be some room for improvement. It looks like it doesn't monitor the expiry time of a token retrieved from cache. I've just pushed an update to that project that should handle this better. Grab the latest code from the dist folder of that project.

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful