1

我正在尝试 IAP 的服务器端 Canceled api,但我无法使用此 api 取消订阅。每次单击取消时,我都会收到此错误: responseCode:"6","re​​sponseMessage":"900030-authorization format invalid"

我使用的 API 是这样的: https ://subscr-dra.iap.hicloud.com/sub/applications/v2/purchases/stop

有人可以帮我解决这个问题吗?

4

3 回答 3

0

The Extension of AT File is incorrect.

Authentication information is specified based on the request header. The details are as follows: App-level access token: Authorization: Basic Base64(APPAT:atvalue)

  • Example: The app-level access token is thisIsAppAtValue, then APPAT:atvalue is APPAT:thisIsAppAtValue. Therefore, replace APPAT:atvalue in Base64(APPAT:atvalue) with APPAT:thisIsAppAtValue, and value QVBQQVQ6dGhpc0lzQXBwQXRWYWx1ZQ== is obtained. The value of Authorization in the request header is as follows: Basic QVBQQVQ6dGhpc0lzQXBwQXRWYWx1ZQ==

The sample code is as follows:

  /* Build Authorization in Header
     *
     * @param appAt app AccessToken
     * @return headers
     */
    public static Map<String, String> buildAuthorization(String appAt) {
        String oriString = MessageFormat.format("APPAT:{0}", appAt);
        String authorization =
            MessageFormat.format("Basic {0}", Base64.encodeBase64String(oriString.getBytes(StandardCharsets.UTF_8)));
        Map<String, String> headers = new HashMap<>();
        headers.put("Authorization", authorization);
        headers.put("Content-Type", "application/json; charset=UTF-8");
        return headers;
}

HMS In-App Purchases(IAP) Severdemo on Github.

于 2020-09-28T02:27:32.647 回答
0

检查您作为授权放入标头的令牌的格式。

代码:

let oriString = 'APPAT:' + app_level_access_token;

let authorizationToken = new Buffer.from(oriString).toString('base64'); // converting the token into Base64.

现在authorizationToken,您可以在标题中使用它。

于 2020-07-10T17:01:42.537 回答
0

您收到的错误码 - 900030 表示您的签名验证数据格式无效。可能的原因有: • 请求标头中的令牌未在 Base64 模式下加密。• 字符串APPAT 未附加到访问令牌的开头以进行授权。正确的访问令牌格式为 APPAT:thisIsAppAtVaule。

您可以在此处阅读有关此错误代码的信息

请确保您的请求遵循本文档中指定的格式

如果您仍然收到相同的错误,请在此处发布您的请求数据格式。

于 2020-11-20T17:56:05.033 回答