I'm trying to do a server-side verification of Huawei subscription, but currently I'm stuck at verification part
Do a base64encode UTF-8 format of string 'APPAT:my_access_token'
Then I'm trying to get purchaseDetails from https://subscr-drcn.iap.hicloud.com/sub/applications/v2/purchases/get. Im sending subscriptionId and purchaseToken in json format and base64encoded access_token in Authorization ('Basic my_access_token') header and Content-Type=application/json;charset=UTF-8
Every time I get this response:
{ "responseCode": "6", "responseMessage": "Token is expired or invalid" }
Searching for this message didn't help. What can be the problem with it? Is it invalid purchaseToken or invalid accessToken?
Please help me with this, thanks!
Please check as follows:
import org.apache.commons.codec.binary.Base64;
* Construct an Authorization field in the request header.
*
* @param appAt App-level access token.
* @return headers Return the request header.
*/
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;
}
/**
For more details, see docs.