Exemplo n.º 1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is CardPaymentDetails other &&
                   ((Status == null && other.Status == null) || (Status?.Equals(other.Status) == true)) &&
                   ((Card == null && other.Card == null) || (Card?.Equals(other.Card) == true)) &&
                   ((EntryMethod == null && other.EntryMethod == null) || (EntryMethod?.Equals(other.EntryMethod) == true)) &&
                   ((CvvStatus == null && other.CvvStatus == null) || (CvvStatus?.Equals(other.CvvStatus) == true)) &&
                   ((AvsStatus == null && other.AvsStatus == null) || (AvsStatus?.Equals(other.AvsStatus) == true)) &&
                   ((AuthResultCode == null && other.AuthResultCode == null) || (AuthResultCode?.Equals(other.AuthResultCode) == true)) &&
                   ((ApplicationIdentifier == null && other.ApplicationIdentifier == null) || (ApplicationIdentifier?.Equals(other.ApplicationIdentifier) == true)) &&
                   ((ApplicationName == null && other.ApplicationName == null) || (ApplicationName?.Equals(other.ApplicationName) == true)) &&
                   ((ApplicationCryptogram == null && other.ApplicationCryptogram == null) || (ApplicationCryptogram?.Equals(other.ApplicationCryptogram) == true)) &&
                   ((VerificationMethod == null && other.VerificationMethod == null) || (VerificationMethod?.Equals(other.VerificationMethod) == true)) &&
                   ((VerificationResults == null && other.VerificationResults == null) || (VerificationResults?.Equals(other.VerificationResults) == true)) &&
                   ((StatementDescription == null && other.StatementDescription == null) || (StatementDescription?.Equals(other.StatementDescription) == true)) &&
                   ((DeviceDetails == null && other.DeviceDetails == null) || (DeviceDetails?.Equals(other.DeviceDetails) == true)) &&
                   ((CardPaymentTimeline == null && other.CardPaymentTimeline == null) || (CardPaymentTimeline?.Equals(other.CardPaymentTimeline) == true)) &&
                   ((RefundRequiresCardPresence == null && other.RefundRequiresCardPresence == null) || (RefundRequiresCardPresence?.Equals(other.RefundRequiresCardPresence) == true)) &&
                   ((Errors == null && other.Errors == null) || (Errors?.Equals(other.Errors) == true)));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles the Navigating event of the Browser control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The event args instance containing the event data.</param>
        private void Browser_Navigating(object sender, NavigatingEventArgs e)
        {
            string host  = e.Uri.Host;
            string query = e.Uri.Query;

            if (!string.IsNullOrEmpty(host) && !string.IsNullOrEmpty(query))
            {
                Debug.WriteLine("Navigating host=" + host + " query=" + query);
                if (string.Compare(this._host, host, StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    AuthResultCode result            = AuthResultCode.Unknown;
                    string         authorizationCode = null;

                    OAuthResultParser.ParseQuerystringForCompletedFlags(query, out result, out authorizationCode);
                    if (result != AuthResultCode.Unknown)
                    {
                        Debug.WriteLine(e.Uri);
                        if (result == AuthResultCode.Success)
                        {
                            this.AuthorizationCode = authorizationCode;
                        }

                        this.ResultCode = result;
                        e.Cancel        = true;
                        this._authWaiter.Set();
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Authenticates a user to enable the user data APIs.
        /// </summary>
        /// <param name="client">The MixRadio client.</param>
        /// <param name="clientSecret">The client secret obtained during app registration</param>
        /// <param name="scopes">The scopes requested.</param>
        /// <param name="oauthRedirectUri">The OAuth completed URI.</param>
        /// <param name="cancellationToken">The cancellation token to cancel operation</param>
        /// <returns>
        /// An AuthResultCode value indicating the result
        /// </returns>
        /// <remarks>
        /// Sorry, this method is messy due to the platform differences!
        /// </remarks>
        public static async Task <AuthResultCode> AuthenticateUserAsync(this MusicClient client, string clientSecret, Scope scopes, string oauthRedirectUri = MusicClient.DefaultOAuthRedirectUri, CancellationToken?cancellationToken = null)
        {
            if (string.IsNullOrEmpty(oauthRedirectUri))
            {
                throw new ArgumentNullException("oauthRedirectUri", "You must supply your OAuth Redirect URI to allow user interaction");
            }

            if (string.IsNullOrEmpty(clientSecret))
            {
                throw new ArgumentNullException("clientSecret", "You must supply your app client secret obtained during app registration");
            }

            // See if we have a cached token...
            AuthResultCode cachedResult = await AuthenticateUserAsync(client, clientSecret, cancellationToken).ConfigureAwait(false);

            if (cachedResult == AuthResultCode.Success)
            {
                return(cachedResult);
            }

#if WINDOWS_PHONE_APP
            WebAuthenticationBroker.AuthenticateAndContinue(client.GetAuthenticationUri(scopes), new Uri(oauthRedirectUri));
            return(AuthResultCode.InProgress);
#elif WINDOWS_APP
            var authResult = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, client.GetAuthenticationUri(scopes), new Uri(oauthRedirectUri));

            return(await CompleteAuthenticateUserAsync(client, clientSecret, authResult, cancellationToken));
#endif
        }
Exemplo n.º 4
0
        public void EnsureErrorCaseQuerystringGivesTrueResult()
        {
            string         authorizationCode = null;
            AuthResultCode resultCode        = AuthResultCode.Unknown;

            OAuthResultParser.ParseQuerystringForCompletedFlags("?error=access_denied&error_description=denied", out resultCode, out authorizationCode);
            Assert.AreEqual(AuthResultCode.AccessDenied, resultCode, "Expected the result code to be set");
            Assert.IsNullOrEmpty(authorizationCode, "Expected a null authorization code");
        }
        public void EnsureEmptyQuerystringGivesFalseResult()
        {
            string         authorizationCode = null;
            AuthResultCode resultCode        = AuthResultCode.Success;

            Assert.AreEqual(false, OAuthResultParser.ParseQuerystringForCompletedFlags(null, out resultCode, out authorizationCode), "Expected a false result");
            Assert.AreEqual(AuthResultCode.Unknown, resultCode, "Expected the result code reset");
            Assert.IsNullOrEmpty(authorizationCode, "Expected a null authorization code");
        }
Exemplo n.º 6
0
        public void EnsureIrrelevantQuerystringGivesFalseResult()
        {
            string         authorizationCode = null;
            AuthResultCode resultCode        = AuthResultCode.Success;

            OAuthResultParser.ParseQuerystringForCompletedFlags("?expectingnullresult=true", out resultCode, out authorizationCode);
            Assert.AreEqual(AuthResultCode.Unknown, resultCode, "Expected the result code reset");
            Assert.IsNullOrEmpty(authorizationCode, "Expected a null authorization code");
        }
Exemplo n.º 7
0
        public void EnsureSuccessQuerystringGivesTrueResult()
        {
            string         authCode          = Guid.NewGuid().ToString();
            string         authorizationCode = null;
            AuthResultCode resultCode        = AuthResultCode.Unknown;

            OAuthResultParser.ParseQuerystringForCompletedFlags("?code=" + authCode, out resultCode, out authorizationCode);
            Assert.AreEqual(AuthResultCode.Success, resultCode, "Expected the result code to be set");
            Assert.AreEqual(authCode, authorizationCode, "Expected the authorization code back");
        }
Exemplo n.º 8
0
        /// <summary>
        /// Authenticates a user to enable the user data APIs.
        /// </summary>
        /// <param name="clientSecret">The client secret obtained during app registration</param>
        /// <param name="scopes">The scopes requested.</param>
        /// <param name="oauthRedirectUri">The OAuth completed URI.</param>
        /// <returns>
        /// An AuthResultCode value indicating the result
        /// </returns>
        /// <remarks>
        /// Sorry, this method is messy due to the platform differences!
        /// </remarks>
        public async Task <AuthResultCode> AuthenticateUserAsync(string clientSecret, Scope scopes, string oauthRedirectUri = MusicClient.DefaultOAuthRedirectUri)
        {
            if (string.IsNullOrEmpty(oauthRedirectUri))
            {
                throw new ArgumentNullException("oauthRedirectUri", "You must supply your OAuth Redirect URI to allow user interaction");
            }
#endif
            if (string.IsNullOrEmpty(clientSecret))
            {
                throw new ArgumentNullException("clientSecret", "You must supply your app client secret obtained during app registration");
            }

            if (this._oauthFlowController != null && this._oauthFlowController.IsBusy)
            {
                throw new InvalidOperationException("An authentication call is in progress already");
            }

            // See if we have a cached token...
            AuthResultCode cachedResult = await this.AuthenticateUserAsync(clientSecret);

            if (cachedResult == AuthResultCode.Success)
            {
                return(cachedResult);
            }

            var cmd = this.CreateCommand <GetAuthTokenCommand>();
            this.SetupSecureCommand(cmd);

            this._oauthFlowController = new OAuthUserFlow(this.ClientId, clientSecret, cmd);

#if WINDOWS_PHONE
            Response <AuthResultCode> response = await this._oauthFlowController.AuthenticateUserAsync(this.SecureBaseApiUri, scopes, browser, cancellationToken);
#elif NETFX_CORE
            Response <AuthResultCode> response = await this._oauthFlowController.AuthenticateUserAsync(new Uri(oauthRedirectUri), this.SecureBaseApiUri, scopes);
#endif
            await this.StoreOAuthToken(this._oauthFlowController.TokenResponse, clientSecret);

            this._oauthFlowController = null;

            if (response.Error != null)
            {
                throw response.Error;
            }
            else
            {
                return(response.Result);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Continues the authenticate user flow by extracting results from the Windows-specific
        /// auth method and moving on to the final common step.
        /// </summary>
        /// <param name="authResult">The result from the WebAuthenticationBroker call.</param>
        /// <returns>
        /// Whether the token was retrieved
        /// </returns>
        internal async Task <Response <AuthResultCode> > ConvertAuthPermissionParams(WebAuthenticationResult authResult)
        {
            try
            {
                switch (authResult.ResponseStatus)
                {
                case WebAuthenticationStatus.Success:

                    // ResponseData will give us the final URI with a Querystring containing an auth code or error details
                    // e.g. code=90e754fd-0a4a-4eb5-b5f6-25dad9face6a or error=access_denied
                    AuthResultCode resultCode        = AuthResultCode.Unknown;
                    string         authorizationCode = null;

                    OAuthResultParser.ParseQuerystringForCompletedFlags(authResult.ResponseData, out resultCode, out authorizationCode);
                    if (resultCode != AuthResultCode.Unknown)
                    {
                        // Move on to obtain a token
                        return(await this.ObtainToken(authorizationCode, null, resultCode));
                    }
                    else
                    {
                        return(new Response <AuthResultCode>(null, AuthResultCode.Unknown, Guid.Empty));
                    }

                case WebAuthenticationStatus.ErrorHttp:
                    switch ((HttpStatusCode)authResult.ResponseErrorDetail)
                    {
                    case HttpStatusCode.BadRequest:
                        return(new Response <AuthResultCode>(null, AuthResultCode.InvalidScope, Guid.Empty));

                    case HttpStatusCode.Unauthorized:
                        return(new Response <AuthResultCode>(null, AuthResultCode.UnauthorizedClient, Guid.Empty));

                    case HttpStatusCode.InternalServerError:
                        return(new Response <AuthResultCode>(null, AuthResultCode.ServerError, Guid.Empty));
                    }

                    // Any other items will return as cancelled below...
                    break;
                }
            }
            catch
            {
                // Usually means we got cancelled
            }

            return(new Response <AuthResultCode>(null, AuthResultCode.Cancelled, Guid.Empty));
        }
Exemplo n.º 10
0
        /// <summary>
        /// Authenticates a user to enable the user data APIs.
        /// </summary>
        /// <param name="client">The MixRadio client.</param>
        /// <param name="clientSecret">The client secret obtained during app registration</param>
        /// <param name="scopes">The scopes requested.</param>
        /// <param name="browser">The browser control to use to drive authentication.</param>
        /// <param name="cancellationToken">The optional cancellation token.</param>
        /// <param name="oauthRedirectUri">The OAuth completed URI.</param>
        /// <returns>
        /// An AuthResultCode value indicating the result
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        /// browser;You must supply a web browser to allow user interaction
        /// or
        /// clientSecret;You must supply your app client secret obtained during app registration
        /// </exception>
        /// <remarks>
        /// Sorry, this method is messy due to the platform differences
        /// </remarks>
        public static async Task <AuthResultCode> AuthenticateUserAsync(this MusicClient client, string clientSecret, Scope scopes, WebBrowser browser, CancellationToken?cancellationToken = null, string oauthRedirectUri = MusicClient.DefaultOAuthRedirectUri)
        {
            if (browser == null)
            {
                throw new ArgumentNullException("browser", "You must supply a web browser to allow user interaction");
            }

            if (string.IsNullOrEmpty(clientSecret))
            {
                throw new ArgumentNullException("clientSecret", "You must supply your app client secret obtained during app registration");
            }

            // See if we have a cached token...
            AuthResultCode cachedResult = await AuthenticateUserAsync(client, clientSecret, cancellationToken).ConfigureAwait(false);

            if (cachedResult == AuthResultCode.Success)
            {
                return(cachedResult);
            }

            var browserController = new OAuthBrowserController();

            CancellationToken token = cancellationToken ?? CancellationToken.None;

            await Task.Run(() => browserController.DriveAuthProcess(browser, client.GetAuthenticationUri(scopes), oauthRedirectUri, token), token);

            AuthResultCode authResult = browserController.ResultCode;

            if (authResult != AuthResultCode.Cancelled)
            {
                // Grab the results and kill the browser controller
                string code = browserController.AuthorizationCode;
                browserController = null;

                // Move on to obtain a token
                if (authResult == AuthResultCode.Success)
                {
                    var authToken = await client.GetAuthenticationTokenAsync(clientSecret, code, cancellationToken);

                    if (authToken != null)
                    {
                        await StoreOAuthToken(authToken, client.ClientId, clientSecret, cancellationToken).ConfigureAwait(false);
                    }
                }
            }

            return(authResult);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Parses the querystring for completed flags.
        /// </summary>
        /// <param name="querystring">The querystring.</param>
        /// <param name="resultCode">The result.</param>
        /// <param name="authorizationCode">The authorization code if one was returned.</param>
        /// <returns>
        /// A boolean indicating that we found appropriate flags to end the flow
        /// </returns>
        internal static bool ParseQuerystringForCompletedFlags(string querystring, out AuthResultCode resultCode, out string authorizationCode)
        {
            bool valid = false;

            authorizationCode = null;
            resultCode        = AuthResultCode.Unknown;

            if (!string.IsNullOrEmpty(querystring))
            {
                string trimmedQuerystring = querystring;

                // Ensure we start from the "?"...
                int queryStart = querystring.IndexOf("?");
                if (queryStart > -1)
                {
                    trimmedQuerystring = querystring.Substring(queryStart + 1);
                }

                string[] queryParams = trimmedQuerystring.Split('&');

                foreach (string pair in queryParams)
                {
                    string[] keyValue = pair.Split('=');
                    if (keyValue.Length == 2 && !string.IsNullOrWhiteSpace(keyValue[1]))
                    {
                        string key = keyValue[0].ToLowerInvariant();

                        switch (key)
                        {
                        case "code":
                            authorizationCode = keyValue[1];
                            resultCode        = AuthResultCode.Success;
                            valid             = true;
                            break;

                        case "error":
                            authorizationCode = null;
                            resultCode        = keyValue[1].ToLowerInvariant().ToAuthResultReason();
                            valid             = true;
                            break;
                        }
                    }
                }
            }

            return(valid);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Continues the authenticate user flow by extracting results from the WP8-specific
        /// auth method and moving on to the final common step.
        /// </summary>
        /// <param name="taskCompleted">if set to <c>true</c> oauth task completed.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// Whether the token was retrieved
        /// </returns>
        internal async Task <Response <AuthResultCode> > ConvertAuthPermissionParamsAndFinalise(bool taskCompleted, CancellationToken?cancellationToken)
        {
            if (taskCompleted)
            {
                // Grab the results and kill the browser controller
                string         authorizationCode = this._browserController.AuthorizationCode;
                AuthResultCode resultCode        = this._browserController.ResultCode;
                this._browserController = null;

                // Move on to obtain a token
                return(await this.ObtainToken(authorizationCode, null, resultCode));
            }
            else
            {
                return(new Response <AuthResultCode>(null, new OperationCanceledException(), null, Guid.Empty));
            }
        }
        /// <summary>
        /// Parses the querystring for completed flags.
        /// </summary>
        /// <param name="querystring">The querystring.</param>
        /// <param name="resultCode">The result.</param>
        /// <param name="authorizationCode">The authorization code if one was returned.</param>
        /// <returns>
        /// A boolean indicating that we found appropriate flags to end the flow
        /// </returns>
        internal static bool ParseQuerystringForCompletedFlags(string querystring, out AuthResultCode resultCode, out string authorizationCode)
        {
            bool valid = false;
            authorizationCode = null;
            resultCode = AuthResultCode.Unknown;

            if (!string.IsNullOrEmpty(querystring))
            {
                string trimmedQuerystring = querystring;

                // Ensure we start from the "?"...
                int queryStart = querystring.IndexOf("?");
                if (queryStart > -1)
                {
                    trimmedQuerystring = querystring.Substring(queryStart + 1);
                }

                string[] queryParams = trimmedQuerystring.Split('&');

                foreach (string pair in queryParams)
                {
                    string[] keyValue = pair.Split('=');
                    if (keyValue.Length == 2 && !string.IsNullOrWhiteSpace(keyValue[1]))
                    {
                        string key = keyValue[0].ToLowerInvariant();

                        switch (key)
                        {
                            case "code":
                                authorizationCode = keyValue[1];
                                resultCode = AuthResultCode.Success;
                                valid = true;
                                break;

                            case "error":
                                authorizationCode = null;
                                resultCode = keyValue[1].ToLowerInvariant().ToAuthResultReason();
                                valid = true;
                                break;
                        }
                    }
                }
            }

            return valid;
        }
Exemplo n.º 14
0
        private void Browser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
        {
            string query = e.Url.Query;
#endif
            if (!string.IsNullOrEmpty(query))
            {
                AuthResultCode result = AuthResultCode.Unknown;
                string authorizationCode = null;

                if (OAuthResultParser.ParseQuerystringForCompletedFlags(query, out result, out authorizationCode))
                {
                    if (result == AuthResultCode.Success)
                    {
                        this.AuthorizationCode = authorizationCode;
                    }
                    
                    this.ResultCode = result;
                    e.Cancel = true;
                    this._authWaiter.Set();
                }
            }
        }
Exemplo n.º 15
0
        private void displayAuthResultCode(AuthResultCode result)
        {
            string message;

            switch (result)
            {
            case AuthResultCode.LoginBadPassword:
                message = ResponseConstants.LOGIN_BAD_PASSWORD;
                break;

            case AuthResultCode.LoginBadUser:
                message = ResponseConstants.LOGIN_BAD_USERNAME;
                break;

            case AuthResultCode.LoginSuccess:
                message = ResponseConstants.LOGIN_SUCCESS;
                break;

            case AuthResultCode.NotAuthenticated:
                message = ResponseConstants.NOT_AUTHENTICATED;
                break;

            case AuthResultCode.RegisterBadUser:
                message = ResponseConstants.REGISTER_BAD_USER;
                break;

            case AuthResultCode.RegisterSuccess:
                message = ResponseConstants.REGISTER_SUCCESS;
                break;

            default:
                message = ResponseConstants.UNKNOWN_ERROR;
                break;
            }

            MessageBox.Show(message);
        }
Exemplo n.º 16
0
        public override int GetHashCode()
        {
            int hashCode = 1465447186;

            if (Status != null)
            {
                hashCode += Status.GetHashCode();
            }

            if (Card != null)
            {
                hashCode += Card.GetHashCode();
            }

            if (EntryMethod != null)
            {
                hashCode += EntryMethod.GetHashCode();
            }

            if (CvvStatus != null)
            {
                hashCode += CvvStatus.GetHashCode();
            }

            if (AvsStatus != null)
            {
                hashCode += AvsStatus.GetHashCode();
            }

            if (AuthResultCode != null)
            {
                hashCode += AuthResultCode.GetHashCode();
            }

            if (ApplicationIdentifier != null)
            {
                hashCode += ApplicationIdentifier.GetHashCode();
            }

            if (ApplicationName != null)
            {
                hashCode += ApplicationName.GetHashCode();
            }

            if (ApplicationCryptogram != null)
            {
                hashCode += ApplicationCryptogram.GetHashCode();
            }

            if (VerificationMethod != null)
            {
                hashCode += VerificationMethod.GetHashCode();
            }

            if (VerificationResults != null)
            {
                hashCode += VerificationResults.GetHashCode();
            }

            if (StatementDescription != null)
            {
                hashCode += StatementDescription.GetHashCode();
            }

            if (DeviceDetails != null)
            {
                hashCode += DeviceDetails.GetHashCode();
            }

            if (CardPaymentTimeline != null)
            {
                hashCode += CardPaymentTimeline.GetHashCode();
            }

            if (RefundRequiresCardPresence != null)
            {
                hashCode += RefundRequiresCardPresence.GetHashCode();
            }

            if (Errors != null)
            {
                hashCode += Errors.GetHashCode();
            }

            return(hashCode);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Finalises authorisation to obtain a token
        /// </summary>
        /// <param name="authorizationCode">The authorization code.</param>
        /// <param name="refreshToken">The refresh token.</param>
        /// <param name="resultCode">The result code for the process so far.</param>
        /// <param name="cancellationToken">The cancellation token to cancel operation</param>
        /// <returns>
        /// Whether the token was retrieved
        /// </returns>
        internal async Task <Response <AuthResultCode> > ObtainToken(string authorizationCode, string refreshToken, AuthResultCode resultCode, CancellationToken?cancellationToken = null)
        {
            // Next get a token, for now just return whether we got the authorization code...
            if (!string.IsNullOrEmpty(authorizationCode) || !string.IsNullOrEmpty(refreshToken))
            {
                Response <AuthResultCode> result = null;

                this.TokenCallInProgress = true;

                // Set up auth code and secret...
                this._tokenCommand.AuthorizationCode = authorizationCode;
                this._tokenCommand.ClientId          = this._clientId;
                this._tokenCommand.ClientSecret      = this._clientSecret;
                this._tokenCommand.RefreshToken      = refreshToken;

                try
                {
                    var tokenResponse = await this._tokenCommand.ExecuteAsync(cancellationToken);

                    if (tokenResponse.Result != null)
                    {
                        result             = new Response <AuthResultCode>(null, AuthResultCode.Success, Guid.Empty);
                        this.TokenResponse = tokenResponse.Result;
                    }
                }
                catch
                {
                    result = new Response <AuthResultCode>(null, AuthResultCode.Unknown, Guid.Empty);
                }

                this.TokenCallInProgress = false;

                return(result);
            }
            else
            {
                return(new Response <AuthResultCode>(null, resultCode, Guid.Empty));
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Finalises authorisation to obtain a token
        /// </summary>
        /// <param name="authorizationCode">The authorization code.</param>
        /// <param name="refreshToken">The refresh token.</param>
        /// <param name="resultCode">The result code for the process so far.</param>
        /// <returns>
        /// Whether the token was retrieved
        /// </returns>
        internal async Task<Response<AuthResultCode>> ObtainToken(string authorizationCode, string refreshToken, AuthResultCode resultCode)
        {
            // Next get a token, for now just return whether we got the authorization code...
            if (!string.IsNullOrEmpty(authorizationCode) || !string.IsNullOrEmpty(refreshToken))
            {
                ManualResetEventSlim waiter = new ManualResetEventSlim();
                Response<AuthResultCode> result = null;

                this.TokenCallInProgress = true;

                // Set up auth code and secret...
                this._tokenCommand.AuthorizationCode = authorizationCode;
                this._tokenCommand.ClientId = this._clientId;
                this._tokenCommand.ClientSecret = this._clientSecret;
                this._tokenCommand.RefreshToken = refreshToken;

                try
                {
                    var tokenResponse = await this._tokenCommand.InvokeAsync();
                    if (tokenResponse.Result != null)
                    {
                        result = new Response<AuthResultCode>(null, AuthResultCode.Success, Guid.Empty);
                        this.TokenResponse = tokenResponse.Result;
                    }
                }
                catch
                {
                    result = new Response<AuthResultCode>(null, AuthResultCode.Unknown, Guid.Empty);
                }

                this.TokenCallInProgress = false;

                return result;
            }
            else
            {
                return new Response<AuthResultCode>(null, resultCode, Guid.Empty);
            }
        }