Esri/resource-proxy

(DOTNET) Token renewal causes "code": 498, "message": "Invalid Token"

shiyiwen opened this issue · 0 comments

If there is a token in context.Application["token_for_" + serverUrl.Url] for a specific uri. The proxy will sent out a request like
http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates?SingleLine=xxx&f=json&outSR=xxx&outFields=*&magicKey=xxx&maxLocations=5&token=existingToken

If the existing token expires, this request will return a response "code": 498, "message": "Invalid Token". and proxy will sent out a request to renew token.

After receiving new token, it will use function addTokenToUri to apply new token in next request.

However, the logic to apply new token in function addTokenToUri ( v1.1.2 proxy.ashx line587) is as following:

private string addTokenToUri(string uri, string token, string tokenParamName) {
if (!String.IsNullOrEmpty(token))
uri += uri.Contains("?")? "&" + tokenParamName + "=" + token : "?" + tokenParamName + "=" + token;
return uri;
}
which append new token to existing uri will return a result as
http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates?SingleLine=xxx&f=json&outSR=xxx&outFields=*&magicKey=xxx&maxLocations=5&token=existingToken&token=newToken

The uri with new token will still return a response "code": 498, "message": "Invalid Token".

Please investigate it. I think we might need to update the logic in addTokenToUri to replace the token if there is already have one in uri.

Thanks for your consideration.