Represents SHOPIFY OAUTH 2.0 authorization state.
Ejemplo n.º 1
0
        private bool ValidateInstallResponse(OAuthState installState)
        {
            var queryStringBuilder = new QueryStringBuilder {
                StartsWith = null
            };

            queryStringBuilder.Add(AppResources.CodeKeyword, installState.AuthorizationCode);
            queryStringBuilder.Add(AppResources.ShopKeyword, installState.ShopName);
            queryStringBuilder.Add(AppResources.TimestampKeyword, installState.AuthorizationTimestamp);
            var secretKeyBytes       = Encoding.UTF8.GetBytes(this.Configuration.SecretKey);
            var installResponseBytes = Encoding.UTF8.GetBytes(queryStringBuilder.ToString());

            using (var hmacsha256 = new HMACSHA256(secretKeyBytes))
            {
                var generatedInstallResponseHmacHashBytes = hmacsha256.ComputeHash(installResponseBytes);
                var generatedInstallResponseHmacHash      = ByteArrayToHexString(generatedInstallResponseHmacHashBytes);
                return(generatedInstallResponseHmacHash.Equals(installState.HmacHash));
            }
        }
Ejemplo n.º 2
0
 private bool ValidateInstallResponse(OAuthState installState)
 {
     var queryStringBuilder = new QueryStringBuilder { StartsWith = null };
     queryStringBuilder.Add(AppResources.CodeKeyword, installState.AuthorizationCode);
     queryStringBuilder.Add(AppResources.ShopKeyword, installState.ShopName);
     queryStringBuilder.Add(AppResources.TimestampKeyword, installState.AuthorizationTimestamp);
     var secretKeyBytes = Encoding.UTF8.GetBytes(this.Configuration.SecretKey);
     var installResponseBytes = Encoding.UTF8.GetBytes(queryStringBuilder.ToString());
     using (var hmacsha256 = new HMACSHA256(secretKeyBytes))
     {
         var generatedInstallResponseHmacHashBytes = hmacsha256.ComputeHash(installResponseBytes);
         var generatedInstallResponseHmacHash = ByteArrayToHexString(generatedInstallResponseHmacHashBytes);
         return generatedInstallResponseHmacHash.Equals(installState.HmacHash);
     }
 }