本文介绍了Shopify oauth中的HMAC-SHA256问题(输出不匹配)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在尝试按照文档在Shopify市场上发布应用。而且我仍然坚持oauth文档的第3步,你需要做'HMAC签名验证'。

I'm trying to publish an app on Shopify marketplace by following this documentation. And I'm stuck on step-3 of the oauth documentation wherein you have to do 'HMAC Signature Validation'.

文档说明你必须处理字符串(指定下面)通过HMAC-SHA256使用应用程序的共享密钥。

Documentation states that you have to process the string (specified below) through HMAC-SHA256 using app's shared secret key.

String = "shop=some-shop.myshopify.com&timestamp=1337178173"

我正在尝试使用Java实现这些步骤。以下是我使用的代码的要点。

I'm trying to implement the steps using Java. Following is gist of the code that I have used.

        private static final String HMAC_ALGORITHM = "HmacSHA256";
        String key = "hush";
        String data = "shop=some-shop.myshopify.com&timestamp=1337178173";
        SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(),HMAC_ALGORITHM);
        Mac mac = Mac.getInstance(HMAC_ALGORITHM);
        mac.init(keySpec);
        byte[] rawHmac = mac.doFinal(data.getBytes());
        System.out.println(Hex.encodeHexString(rawHmac));

代码生成以下字符串:

c2812f39f84c32c2edaded339a1388abc9829babf351b684ab797f04cd94d4c7

通过Shopify开发者论坛上的一些随机搜索,我找到了指向。

Through some random search on Shopify developer forum I found the link to a question.

来自

这篇关于Shopify oauth中的HMAC-SHA256问题(输出不匹配)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 17:30