我正在使用 Google.Apis.AndroidPublisher.v2 获取应用内产品:列表和应用内购买详细信息。我已在应用程序控制台中创建了一个新的服务帐户,并根据需要使用 .p12 key 。这是我的代码:
String serviceAccountEmail = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9cf5fdecb1adada5dcfdfeffb2f5fdf1b2fbeff9eeeaf5fff9fdfffff3e9f2e8b2fff3f1" rel="noreferrer noopener nofollow">[email protected]</a>";
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 商店。
谢谢
最佳答案
我已经找到解决办法了。需要在 Google Play 管理中心的“API 访问”页面上将服务帐户添加为链接帐户。还可以在开发者控制台中将服务帐户电子邮件添加为具有所需权限的用户。
关于asp.net - asp.net 上的 AndroidPublisher 库给出错误“未找到给定包名称的应用程序”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49260402/