private static void Authenticate( WebAuthenticateInteraction webAuthenticate )
        {
            Contract.Requires( webAuthenticate != null );
            
            var requestUri = webAuthenticate.RequestUri;
            var callbackUri = webAuthenticate.CallbackUri ?? WebAuthenticationBroker.GetCurrentApplicationCallbackUri();
            var options = webAuthenticate.Options;
            var continuationData = new ValueSet();

            continuationData.AddRange( webAuthenticate.ContinuationData );

            WebAuthenticationBroker.AuthenticateAndContinue( requestUri, callbackUri, continuationData, options );
        }
        public static Task<IWebAuthenticationResult> RequestAsync( this InteractionRequest<WebAuthenticateInteraction> interactionRequest, WebAuthenticateInteraction interaction )
        {
            Arg.NotNull( interactionRequest, nameof( interactionRequest ) );
            Arg.NotNull( interaction, nameof( interaction ) );

            var source = new TaskCompletionSource<IWebAuthenticationResult>();

            // commands cannot be defined by caller in order to hook up completion
            interaction.Commands.Clear();
            interaction.Commands.Add( new NamedCommand<IWebAuthenticationResult>( "OK", p => source.TrySetResult( p ) ) );
            interaction.Commands.Add( new NamedCommand<IWebAuthenticationResult>( "Cancel", p => source.TrySetResult( p ) ) );
            interactionRequest.Request( interaction );

            return source.Task;
        }
        private static void InvokeCallbackCommand( WebAuthenticateInteraction webAuthenticate, WebAuthenticationResult authenticationResult )
        {
            Contract.Requires( webAuthenticate != null );
            Contract.Requires( authenticationResult != null );

            IWebAuthenticationResult result = null;

            if ( authenticationResult.ResponseStatus == WebAuthenticationStatus.Success )
            {
                result = new WebAuthenticationResultAdapter( authenticationResult );
                webAuthenticate.ResponseStatus = 200U;
                webAuthenticate.ResponseData = authenticationResult.ResponseData;
                webAuthenticate.DefaultCommand?.Execute( result );
            }
            else
            {
                webAuthenticate.ResponseStatus = authenticationResult.ResponseErrorDetail;
                webAuthenticate.CancelCommand?.Execute( result );
            }
        }