PayPal.SOAP.MerchantAPICallPreHandler.GetCredentials C# (CSharp) Method

GetCredentials() private method

Returns the credentials as configured in the application configuration
private GetCredentials ( ) : PayPal.Authentication.ICredential
return PayPal.Authentication.ICredential
        private ICredential GetCredentials()
        {
            ICredential returnCredential = null;
            try
            {
                CredentialManager credentialMngr = CredentialManager.Instance;
                returnCredential = credentialMngr.GetCredentials(this.config, apiUserName);

                if (!string.IsNullOrEmpty(accessToken))
                {

                    // Set third party authorization to token
                    // if token is sent as part of request call
                    IThirdPartyAuthorization thirdPartyAuthorization = new TokenAuthorization(accessToken, tokenSecret);
                    if (returnCredential is SignatureCredential)
                    {
                        SignatureCredential signCredential = (SignatureCredential)returnCredential;
                        signCredential.ThirdPartyAuthorization = thirdPartyAuthorization;
                    }
                    else if (returnCredential is CertificateCredential)
                    {
                        CertificateCredential certCredential = (CertificateCredential)returnCredential;
                        certCredential.ThirdPartyAuthorization = thirdPartyAuthorization;
                    }
                }
            }
            catch(System.Exception ex)
            {
                throw ex;
            }
            return returnCredential;
        }