Solved! Go to Solution.
<serverItem url="http://route.arcgis.com/arcgis/rest/services" matchAll="true" client_id="<client_id>" client_secret="<client_secret>" permitted_referer="http://localhost" tokenUrl="https://www.arcgis.com/sharing/oauth2/token" />
if (theToken == null)
{
string tokenServiceUrl = string.Format("{0}?client_id={1}&client_secret={2}",
si.TokenUrl, si.Client_id, si.Client_secret);
int timeout = 60;
if (si.Timeout > 0)
timeout = si.Timeout;
tokenServiceUrl += string.Format("&expiration={0}", timeout);
DateTime endTime = DateTime.Now.AddMinutes(timeout);
tokenServiceUrl += "&grant_type=client_credentials"; if (string.IsNullOrEmpty(token))
token = generateToken(uri);
string[] sTokenParts = token.Split('"');
if (!String.IsNullOrEmpty(token))
{
if (uri.Contains("?"))
uri += "token=" + sTokenParts[3]; //token;Is it possible to pass our AGOL credentials so public users will never have to log-in?
Do I need to hardcode my AGOL username / password somewhere?
What do I use for the referer?
<serverItem url="http://route.arcgis.com/arcgis/rest/services" matchAll="true" client_id="<client_id>" client_secret="<client_secret>" permitted_referer="http://localhost" tokenUrl="https://www.arcgis.com/sharing/oauth2/token" />
if (theToken == null)
{
string tokenServiceUrl = string.Format("{0}?client_id={1}&client_secret={2}",
si.TokenUrl, si.Client_id, si.Client_secret);
int timeout = 60;
if (si.Timeout > 0)
timeout = si.Timeout;
tokenServiceUrl += string.Format("&expiration={0}", timeout);
DateTime endTime = DateTime.Now.AddMinutes(timeout);
tokenServiceUrl += "&grant_type=client_credentials"; if (string.IsNullOrEmpty(token))
token = generateToken(uri);
string[] sTokenParts = token.Split('"');
if (!String.IsNullOrEmpty(token))
{
if (uri.Contains("?"))
uri += "token=" + sTokenParts[3]; //token;