dwtimmins

Using IdentityManager to generate a short lived token

Discussion created by dwtimmins on Nov 14, 2013
Latest reply on Dec 16, 2013 by dbroux-esristaff
Hi,

just thought I'd post a quick note about generating tokens with the IdentityManager.

The IdentityManager tries to determine the url to use for generating a token based on the url you supply and this works so long as you have /rest/services or /sharing in your url

var credential = await IdentityManager.Current.GenerateCredentialTaskAsync(@"http://serverapps10.esri.com/arcgis/rest/services", "user1", "pass.word1");


However if you just try creating one for the server url like http://serverapps10.esri.com/arcgis it will fail. You can get around this by registering the server first though

var serverInfo = new ESRI.ArcGIS.Client.IdentityManager.ServerInfo { ServerUrl = @"http://serverapps10.esri.com/arcgis" };
            IdentityManager.Current.RegisterServers(new[] { serverInfo });
      
            var credential = await IdentityManager.Current.GenerateCredentialTaskAsync(@"http://serverapps10.esri.com/arcgis", "user1", "pass.word1");

Outcomes