Example #1
0
        public static AccessToken GetAccessToken(WeChatPayConfig config, string code)
        {
            if (string.IsNullOrEmpty(code))
            {
                throw new Exception("Authentication code must be provided");
            }
            AccessToken            token       = null;
            AuthAccessTokenRequest authRequest = new AuthAccessTokenRequest(config);

            authRequest.code = code;
            BaseResponse res = authRequest.Execute();

            if (res != null)
            {
                token = ((AccessTokenResponse)res).Access_Token;
            }
            return(token);
        }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (AuthTokenProviderTitle != null)
         {
             hashCode = hashCode * 59 + AuthTokenProviderTitle.GetHashCode();
         }
         if (AuthTokenProviderDefaultClaims != null)
         {
             hashCode = hashCode * 59 + AuthTokenProviderDefaultClaims.GetHashCode();
         }
         if (AuthTokenProviderEndpoint != null)
         {
             hashCode = hashCode * 59 + AuthTokenProviderEndpoint.GetHashCode();
         }
         if (AuthAccessTokenRequest != null)
         {
             hashCode = hashCode * 59 + AuthAccessTokenRequest.GetHashCode();
         }
         if (AuthTokenProviderKeypairAlias != null)
         {
             hashCode = hashCode * 59 + AuthTokenProviderKeypairAlias.GetHashCode();
         }
         if (AuthTokenProviderConnTimeout != null)
         {
             hashCode = hashCode * 59 + AuthTokenProviderConnTimeout.GetHashCode();
         }
         if (AuthTokenProviderSoTimeout != null)
         {
             hashCode = hashCode * 59 + AuthTokenProviderSoTimeout.GetHashCode();
         }
         if (AuthTokenProviderClientId != null)
         {
             hashCode = hashCode * 59 + AuthTokenProviderClientId.GetHashCode();
         }
         if (AuthTokenProviderScope != null)
         {
             hashCode = hashCode * 59 + AuthTokenProviderScope.GetHashCode();
         }
         if (AuthTokenProviderReuseAccessToken != null)
         {
             hashCode = hashCode * 59 + AuthTokenProviderReuseAccessToken.GetHashCode();
         }
         if (AuthTokenProviderRelaxedSsl != null)
         {
             hashCode = hashCode * 59 + AuthTokenProviderRelaxedSsl.GetHashCode();
         }
         if (TokenRequestCustomizerType != null)
         {
             hashCode = hashCode * 59 + TokenRequestCustomizerType.GetHashCode();
         }
         if (AuthTokenValidatorType != null)
         {
             hashCode = hashCode * 59 + AuthTokenValidatorType.GetHashCode();
         }
         return(hashCode);
     }
 }
        /// <summary>
        /// Returns true if ComAdobeGraniteAuthOauthAccesstokenProviderProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of ComAdobeGraniteAuthOauthAccesstokenProviderProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ComAdobeGraniteAuthOauthAccesstokenProviderProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                     ) &&
                 (
                     AuthTokenProviderTitle == other.AuthTokenProviderTitle ||
                     AuthTokenProviderTitle != null &&
                     AuthTokenProviderTitle.Equals(other.AuthTokenProviderTitle)
                 ) &&
                 (
                     AuthTokenProviderDefaultClaims == other.AuthTokenProviderDefaultClaims ||
                     AuthTokenProviderDefaultClaims != null &&
                     AuthTokenProviderDefaultClaims.Equals(other.AuthTokenProviderDefaultClaims)
                 ) &&
                 (
                     AuthTokenProviderEndpoint == other.AuthTokenProviderEndpoint ||
                     AuthTokenProviderEndpoint != null &&
                     AuthTokenProviderEndpoint.Equals(other.AuthTokenProviderEndpoint)
                 ) &&
                 (
                     AuthAccessTokenRequest == other.AuthAccessTokenRequest ||
                     AuthAccessTokenRequest != null &&
                     AuthAccessTokenRequest.Equals(other.AuthAccessTokenRequest)
                 ) &&
                 (
                     AuthTokenProviderKeypairAlias == other.AuthTokenProviderKeypairAlias ||
                     AuthTokenProviderKeypairAlias != null &&
                     AuthTokenProviderKeypairAlias.Equals(other.AuthTokenProviderKeypairAlias)
                 ) &&
                 (
                     AuthTokenProviderConnTimeout == other.AuthTokenProviderConnTimeout ||
                     AuthTokenProviderConnTimeout != null &&
                     AuthTokenProviderConnTimeout.Equals(other.AuthTokenProviderConnTimeout)
                 ) &&
                 (
                     AuthTokenProviderSoTimeout == other.AuthTokenProviderSoTimeout ||
                     AuthTokenProviderSoTimeout != null &&
                     AuthTokenProviderSoTimeout.Equals(other.AuthTokenProviderSoTimeout)
                 ) &&
                 (
                     AuthTokenProviderClientId == other.AuthTokenProviderClientId ||
                     AuthTokenProviderClientId != null &&
                     AuthTokenProviderClientId.Equals(other.AuthTokenProviderClientId)
                 ) &&
                 (
                     AuthTokenProviderScope == other.AuthTokenProviderScope ||
                     AuthTokenProviderScope != null &&
                     AuthTokenProviderScope.Equals(other.AuthTokenProviderScope)
                 ) &&
                 (
                     AuthTokenProviderReuseAccessToken == other.AuthTokenProviderReuseAccessToken ||
                     AuthTokenProviderReuseAccessToken != null &&
                     AuthTokenProviderReuseAccessToken.Equals(other.AuthTokenProviderReuseAccessToken)
                 ) &&
                 (
                     AuthTokenProviderRelaxedSsl == other.AuthTokenProviderRelaxedSsl ||
                     AuthTokenProviderRelaxedSsl != null &&
                     AuthTokenProviderRelaxedSsl.Equals(other.AuthTokenProviderRelaxedSsl)
                 ) &&
                 (
                     TokenRequestCustomizerType == other.TokenRequestCustomizerType ||
                     TokenRequestCustomizerType != null &&
                     TokenRequestCustomizerType.Equals(other.TokenRequestCustomizerType)
                 ) &&
                 (
                     AuthTokenValidatorType == other.AuthTokenValidatorType ||
                     AuthTokenValidatorType != null &&
                     AuthTokenValidatorType.Equals(other.AuthTokenValidatorType)
                 ));
        }