private void UpdateAuthenticationManager()
{
// Define the server information for ArcGIS Online
ServerInfo portalServerInfo = new ServerInfo();
// ArcGIS Online URI
portalServerInfo.ServerUri = new Uri(ArcGISOnlineUrl);
// Type of token authentication to use
portalServerInfo.TokenAuthenticationType = TokenAuthenticationType.OAuthImplicit;
// Define the OAuth information
OAuthClientInfo oAuthInfo = new OAuthClientInfo
{
ClientId = AppClientId,
RedirectUri = new Uri(OAuthRedirectUrl)
};
portalServerInfo.OAuthClientInfo = oAuthInfo;
// Get a reference to the (singleton) AuthenticationManager for the app
AuthenticationManager thisAuthenticationManager = AuthenticationManager.Current;
// Register the ArcGIS Online server information with the AuthenticationManager
thisAuthenticationManager.RegisterServer(portalServerInfo);
// Create a new ChallengeHandler that uses a method in this class to challenge for credentials
thisAuthenticationManager.ChallengeHandler = new ChallengeHandler(CreateCredentialAsync);
}