我正在使用谷歌API验证用户购买应用程序: Purchases.products:get https://developers.google.com/android-publisher/api-ref/purchases/products/get
在后端的C#中,我用这个url创建HttpWebRequest:
var url = string.Format("https://www.googleapis.com/androidpublisher/v2/applications/{0}/purchases/products/{1}/tokens/{2}", packageName, androidProductId, token);
var request = HttpWebRequest.Create(url);
request.Method = "GET";
正确设置了参数packageName,productId和token。 发送请求后,谷歌用下一个JSON对象回答我:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
所以,问题在于授权我的后端服务器。怎么能修好?