you can use a proxy page. Here you can set your period of time ect.
I have attached an example of proxy modified for call dynamic token in proxy page
In method gettokens you can change your rules
Code:
public string GetToken(string uri)
{
foreach (ServerUrl su in serverUrls)
{
if (su.MatchAll && uri.StartsWith(su.Url, StringComparison.InvariantCultureIgnoreCase) && su.DynamicToken)
{
// Code to dynamically get the token
string tokenService = string.Format("https://{0}/arcgis/tokens?request=getToken&username={1}&password={2}&expiration=30", su.Host, su.UserName, su.Password);
string token;
// This script is added to force the application to certify the SSL script (if for example you have a self certificate on server)
System.Net.ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return true;
};
System.Net.WebRequest tokenRequest = System.Net.WebRequest.Create(tokenService);
System.Net.WebResponse tokenResponse = tokenRequest.GetResponse();
System.IO.Stream responseStream = tokenResponse.GetResponseStream();
System.IO.StreamReader readStream = new System.IO.StreamReader(responseStream);
token = readStream.ReadToEnd();
return token;
}
else if (su.MatchAll && uri.StartsWith(su.Url, StringComparison.InvariantCultureIgnoreCase))
{
return su.Token;
}
else
{
if (String.Compare(uri, su.Url, StringComparison.InvariantCultureIgnoreCase) == 0)
return su.Token;
}
}
if (mustMatch)
throw new InvalidOperationException();
return string.Empty;
}
Bookmarks