我正在尝试对华为订阅进行服务器端验证,但目前我停留在验证部分
对字符串'APPAT:my_access_token'执行base64encoding UTF-8格式
然后,我试图从https://subscr-drcn.iap.hicloud.com/sub/applications/v2/purchases/get获取purchaseDetails 。我以json格式发送subscriptionId和purchaseToken,并在授权('Basic my_access_token')标头和Content-Type = application / json; charset = UTF-8中使用base64编码的access_token
每当我收到这个回应时:
{“ responseCode”:“ 6”,“ responseMessage”:“令牌已过期或无效”}
搜索此消息没有帮助。这可能是什么问题?是无效的purchaseToken还是无效的accessToken?
请帮助我,谢谢!
请检查以下内容:
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;
}
/**
有关更多详细信息,请参阅docs。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句