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); });
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.