public MainPage() { InitializeComponent(); OAuthAuthorize.Initialize(SERVERURL); } private void SignInButton_Click(object sender, RoutedEventArgs e) { var oauthClientInfo = new IdentityManager.OAuthClientInfo(); oauthClientInfo.OAuthAuthorize = new OAuthAuthorize(); oauthClientInfo.ClientId = APPID; oauthClientInfo.RedirectUri = REDIRECTURL; oauthClientInfo.CallbackUrl = CALLBACKURL; var svrInfo = new IdentityManager.ServerInfo(); svrInfo.TokenAuthenticationType = IdentityManager.TokenAuthenticationType.OAuthAuthorizationCode; svrInfo.ServerUrl = SERVERURL; svrInfo.OAuthClientInfo = oauthClientInfo; var svrInfos = new List<IdentityManager.ServerInfo>(); svrInfos.Add(svrInfo); var im = IdentityManager.Current; im.RegisterServers(svrInfos); try { IdentityManager.GenerateTokenOptions options = new IdentityManager.GenerateTokenOptions(); options.OAuthAuthorize = oauthClientInfo.OAuthAuthorize; options.TokenAuthenticationType = IdentityManager.TokenAuthenticationType.OAuthImplicit; im.GenerateCredentialAsync(SERVERURL, (credential, error) => { if (error == null && credential != null) { im.AddCredential(credential); this.SignInButton.Visibility = Visibility.Collapsed; this.UserNameTextBlock.Text = credential.UserName; this.UserNameStackPanel.Visibility = Visibility.Visible; this.SignOutButton.Visibility = Visibility.Visible; LoadWebMap(credential); } }, options); } }
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.