private void UpdateAuthenticationManager()
{
// Register the server information with the AuthenticationManager
ServerInfo portalServerInfo = new ServerInfo
{
ServerUri = new Uri(ArcGISOnlineUrl),
OAuthClientInfo = new OAuthClientInfo
{
ClientId = AppClientId,
RedirectUri = new Uri(OAuthRedirectUrl)
},
// Specify OAuthAuthorizationCode if you need a refresh token (and have specified a valid client secret)
// Otherwise, use OAuthImplicit
TokenAuthenticationType = TokenAuthenticationType.OAuthImplicit
};
// Get a reference to the (singleton) AuthenticationManager for the app
AuthenticationManager thisAuthenticationManager = AuthenticationManager.Current;
// Register the server information
thisAuthenticationManager.RegisterServer(portalServerInfo);
// Assign the method that AuthenticationManager will call to challenge for secured resources
thisAuthenticationManager.ChallengeHandler = new ChallengeHandler(CreateCredentialAsync);
// Set the OAuth authorization handler to this class (Implements IOAuthAuthorize interface)
thisAuthenticationManager.OAuthAuthorizeHandler = this;
}