To programmatically generate a token, it seems that we must set the IdentityManager.Current.ChallengeMethod to the proper method which can give user/pw, and then call GenerateCredentialAsync from within the challenge method.
private Task InitIdentityManager() { var tcs = new TaskCompletionSource<bool>(); IdentityManager.Current.TokenGenerationReferer = "arcgis.com"; IdentityManager.Current.ChallengeMethodEx += SignInDialog.DoSignInEx; // activate the IM with the standard SignInDialog IdentityManager.Current.GenerateCredentialAsync("http://www.arcgis.com/sharing/rest", "username", "password", (crd, error) => { if (crd != null) { IdentityManager.Current.AddCredential(crd); tcs.SetResult(true); } else tcs.SetException(error ?? new Exception("Unknown error")); }); return tcs.Task; }
IdentityManager.Current.GetCredentialAsync("http://www.arcgis.com/sharing/rest", true, (crd, error) => { if (crd != null) IdentityManager.Current.AddCredential(crd); });
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.