Shopee Open Platform API always response “Invalid token”

丶灬走出姿态 提交于 2021-02-11 17:12:52

问题


I'm sorry in advance if something bring you here and I talk about a platform that's not really well-known over the world despite featuring a well-known person dancing in their commercial.

It's Shopee Open Platform API I talk about. I was trying to follow very properly their instruction here.

https://open.shopee.com/documents?module=63&type=2&id=51

But stuck instantly at step 5 : Shop Authorization. First, I've been given a test partner id, a test key, and I need to set manually the test redirect URL. I have to generate authorization token from all given information. Firstly I need to create a token base string by concatenating the test key with URI component encoded string of the URL. It turns into something like this.

9b754aca01a5d719cb70c5778294dae6ff90fcc68c82908ee480a36ff901d181https%3A%2F%2Fwww.unwelldocumented.com

To generate the authorization token, it says I need to do hexencode(sha256(token_base_string)). It returned a very long integer.

32373935663639356636346266303137613465396239383361373334646133656530313333393762636138396364663037366566313366313436316534303761

So I just assumed everything is fine and that is the authorization token. But when I send this...

https://partner.uat.shopeemobile.com/api/v1/shop/auth_partner?id=(test_partner_id)&token=(authorization_token)&redirect=(test_redirect_URL)

... suddenly I get this

{
    "error": "error_auth",
    "msg": "Invalid token",
    "request_id": "30a4b6b0074541bdd88260a33f155ca6"
}

回答1:


In order to solve this, you have to understand that SHA256 is an Encryption hash function. Please research more on SHA256 on your specific language. For this very specific case, your SHA256 token should be as below.

Before SHA256:

9b754aca01a5d719cb70c5778294dae6ff90fcc68c82908ee480a36ff901d181https%3A%2F%2Fwww.unwelldocumented.com

After SHA256:

2795f695f64bf017a4e9b983a734da3ee013397bca89cdf076ef13f1461e407a

The rest of your steps seems correct.



来源:https://stackoverflow.com/questions/61359273/shopee-open-platform-api-always-response-invalid-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!