我正在使用 Google.Apis.AndroidPublisher.v2 来获取Inappproducts:list和inapp购买详情。我已在应用控制台中创建了一个新的服务帐户,并根据需要使用.p12密钥。这是我的代码:
String serviceAccountEmail = "iap-119@abc.iam.gserviceaccount.com";
var fullPath = System.Web.Hosting.HostingEnvironment.MapPath(@"~/App_Data/key.p12");
var certificate = new X509Certificate2(fullPath, "notasecret", X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] { "https://www.googleapis.com/auth/androidpublisher" }
}.FromCertificate(certificate));
var service = new AndroidPublisherService(
new BaseClientService.Initializer()
{
ApplicationName = "abc",
HttpClientInitializer = credential
});
var request = service.Inappproducts.List("com.Its.abc");
var purchaseState = request.Execute();
我在request.Execute(); 消息[找不到给定包名称的应用程序。]位置[packageName - 参数]原因[applicationNotFound]域[全局]
但是我的包名是正确的,并且在Play商店上传了相同的包名。
谢谢,
答案 0 :(得分:1)
我找到了解决方案。需要在" API访问"上添加服务帐户作为链接帐户Google Play控制台上的页面。还要在具有所需权限的开发人员控制台中以用户身份添加服务帐户电子邮件。