How to authentication mapservice with username and password?

3087
2
Jump to solution
10-08-2014 09:18 PM
ItthisakPhueaksri
New Contributor

In api-reference, I found solution for authentication with token base which I need to use a proxy page.

I would appreciate, if you give me some suggestion for do it without a proxy page.

0 Kudos
1 Solution

Accepted Solutions
RexHansen
Esri Contributor
0 Kudos
2 Replies
RexHansen
Esri Contributor
0 Kudos
DominiqueBroux
Esri Frequent Contributor

The sample that Rex pointed out demonstrates how to develop your own SignIn UI.

Alternatively, for WinPhone and Desktop platforms, you can use the UI provided by the toolkit and the SignInChallengeHandler component.

To activate this component, add this line of code at the startup of your application:

  IdentityManager.Current.ChallengeHandler = new Esri.ArcGISRuntime.Toolkit.Security.SignInChallengeHandler();

Compared to the sample, the toolkit SignInChallengeHandler component offers additional advantages:

  • manage all authentication types (token, HTTP secured, PKI (for desktop), OAuth(if setting the OAuthAuthorizeHandler))
  • allow credentials storage so the user can automatically get logged when launching again your application.

The credentials storage is not active by default. To get it, you need to set to true the property AllowSaveCredentials:

  IdentityManager.Current.ChallengeHandler = new Esri.ArcGISRuntime.Toolkit.Security.SignInChallengeHandler

    { AllowSaveCredentials = true, CredentialSaveOption = CredentialSaveOption.Selected }; // set it to CredentialSaveOption.Hidden if it's not an user choice

Note that for WinStore platform, the SignIn UI component is built in the API, so you get it by default.

However the credentials storage is not active by default. You can activate it with code like:

var challengeHandler = IdentityManager.Current.ChallengeHandler as DefaultChallengeHandler;

  challengeHandler.AllowSaveCredentials = true;

0 Kudos