Example #1
0
        /// <summary>
        /// Sets authentication response from the webview or broker for token acquisition continuation.
        /// </summary>
        /// <param name="requestCode">Request response code</param>
        /// <param name="resultCode">Result code from authentication</param>
        /// <param name="data">Response data from authentication</param>
        public static void SetAuthenticationAgentContinuationEventArgs(int requestCode, Result resultCode, Intent data)
        {
            AuthorizationResult authorizationResult = null;

            PlatformPlugin.Logger.Information(null, string.Format(CultureInfo.InvariantCulture, "Received Activity Result({0})", (int)resultCode));
            switch ((int)resultCode)
            {
            case (int)Result.Ok:
                authorizationResult = new AuthorizationResult(AuthorizationStatus.Success, data.GetStringExtra("ReturnedUrl"));
                break;

            case (int)Result.Canceled:
                authorizationResult = new AuthorizationResult(AuthorizationStatus.UserCancel, null);
                break;

            case BrokerResponseCode.ResponseReceived:
            case BrokerResponseCode.BrowserCodeError:
            case BrokerResponseCode.UserCancelled:
                BrokerHelper.SetBrokerResult(data, (int)resultCode);
                break;

            default:
                authorizationResult = new AuthorizationResult(AuthorizationStatus.UnknownError, null);
                break;
            }

            if (authorizationResult != null)
            {
                WebUI.SetAuthorizationResult(authorizationResult);
            }
        }
        public static void SetAuthenticationAgentContinuationEventArgs(int requestCode, Result resultCode, Intent data)
        {
            AuthorizationResult authorizationResult;

            switch (resultCode)
            {
            case Result.Ok: authorizationResult = new AuthorizationResult(AuthorizationStatus.Success, data.GetStringExtra("ReturnedUrl")); break;

            case Result.Canceled: authorizationResult = new AuthorizationResult(AuthorizationStatus.UserCancel, null); break;

            default: authorizationResult = new AuthorizationResult(AuthorizationStatus.UnknownError, null); break;
            }

            WebUI.SetAuthorizationResult(authorizationResult);
        }