I found that it is necessary to use the OAuthAuthorize.Initialize method.https://developers.arcgis.com/silverlight/api-reference/ESRI.ArcGIS.Client.Toolkit~ESRI.ArcGIS.Clien...The part of sample code is below and it works successfully.However, I don't know whether my implement is right or not, because the online sample is not provided.Is this code right? 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);
}
}