AnsweredAssumed Answered

Use secured FeatureLayer from ArcGIS Online

Question asked by ti@rapidis.com on Dec 15, 2014
Latest reply on Dec 15, 2014 by dbroux-esristaff

Simple question:

 

How do I display a secured feature layer on a map in an ArcGIS Runtime for WPF app?

 

I do not want to query the user for username/password. I just want to hardcode it.

 

I know that I need to use IdentityManager and I have successfully done precisely the above with ArcGIS Server, but for some reason it is not working for me with ArcGIS Online.

 

This is what I do for ArcGIS Server. I call this function before I use the secured service (it is a GP-service):

 

 

private async Task GenerateToken(string tokenUrl, string username, string password)

{

 

  IdentityManager.Current.DefaultReferer = "BlahBlah";

 

  IdentityManager.Current.ChallengeMethodEx += SignInDialog.DoSignInEx; // I don't think that this has any effect.


  IdentityManager.Credential crd = await IdentityManager.Current.GenerateCredentialTaskAsync(tokenUrl, username, password);

 

  if (crd != null)

 

    IdentityManager.Current.AddCredential(crd);

 

  else

    throw new Exception("Unknown error");

 

}

 

I think that at least two things are different with ArcGIS Online:

- I do not know what to use for the tokenUrl.

- I would prefer to somehowget this taken care of during application startup. I want the layer to display as soon as the application is loaded.

Outcomes