Huawei Subscription Validation ResponseCode:6 ResponseMessage:Token is expired or invalid InappPurchaseData

122 views Asked by At

I'm trying to verify subscription purchase in our backend servers, considering from this hms-iap-serverdemo GitHub repo.

I'm trying to connect OAuth 2.0-based authentication servers using app ID and app secret. I took ID and secret from AppGallery Connect → my app → app information. The auth servers returns base64 encoded token. When I try to verify with this subscription purchase, I am getting ResponseCode:6 ResponseMessage:Token is expired or invalid InappPurchaseData error from server.

The status of the application is currently draft. Is that why I'm getting this error? I believe client ID and client secret is correct. Or something else. I do not know. Do you have an idea?

Thank you

1

There are 1 answers

2
zhangxaochen On

ResponseCode:6 ResponseMessage:Token is expired or invalid InappPurchaseData

The possible causes are as follows:

  1. Check whether the token is invalid.The token validity period is 1 hour. If the token expires, obtain a new token to ensure that the token is valid.

Check whether the AT is invalid and whether only the AT in the cache is obtained. If the AT is invalid, clear the cache and obtain the AT again. Generally, use the token interface to obtain the application-level AT again.

For details about how to obtain the application level AT, see docs.

  1. The token format is incorrect.

According to the docs: 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" to generate value QVBQQVQ6dGhpc0lzQXBwQXRWYWx1ZQ==.

The value of Authorization in the request header is as follows: Basic QVBQQVQ6dGhpc0lzQXBwQXRWYWx1ZQ==

  1. The site request is incorrect.

Switch to a proper site based on your location and try again.

China: https://subscr-drcn.iap.hicloud.com

Germany: https://subscr-dre.iap.hicloud.com

Singapore: https://subscr-dra.iap.hicloud.com

Russia: https://subscr-drru.iap.hicloud.com