You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

跨项目服务账号调用Google Play Developer API时提示原项目未启用API的问题求助

跨项目服务账号调用Google Play Developer API时提示原项目未启用API的问题求助

各位好,我现在碰到了一个跨项目使用服务账号调用Google Play Android Developer API的棘手问题,想请教下大家怎么解决:

我的现有配置是这样的:

  • 我只能在一个共享项目ProjectA里创建服务账号(SA),这个项目的唯一用途就是生成服务账号
  • 之后我把这个SA邀请到了自己的项目ProjectB中,形成了跨项目的服务账号
  • 我已经在ProjectB里启用了Google Play Android Developer API,使用的是.NET谷歌客户端库来做身份认证和API调用

但现在遇到了奇怪的问题:明明我在代码里指定了ProjectB的ID作为ApplicationName,调用API时却收到报错,说ProjectA没有启用这个API。

下面是我的代码片段:

获取服务账号凭证的方法

public static GoogleCredential GetCredential()
{
    string[] APIscopes = new string[] { AndroidPublisherService.Scope.Androidpublisher  };
    GoogleCredential credential = GoogleCredential.FromFile(KEY_FILE).CreateScoped(APIscopes);
    return credential;
}

创建AndroidPublisherService的方法

public static AndroidPublisherService GetService()
{
    AndroidPublisherService service = new AndroidPublisherService(new BaseClientService.Initializer()
    {
        HttpClientInitializer = GetCredential(),
        ApplicationName = ProjectID // 这里的ProjectID是我的ProjectB的ID
    });
    //Console.WriteLine(service.ApplicationName);
    return service;
}

触发错误的调用

只有当我执行下面这行代码时,才会抛出错误:

service.Users.List("developers/*").Execute();

错误详情

Google.GoogleApiException
HResult=0x80131500
Message=The service androidpublisher has thrown an exception. HttpStatusCode is Forbidden. Google Play Android Developer API has not been used in project PROJECTA_ID before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/androidpublisher.googleapis.com/overview?project=PROJECTAID then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.

有没有朋友遇到过类似的情况?怎么才能让服务账号使用ProjectB的API权限来调用呢?


备注:内容来源于stack exchange,提问作者Lucas Stern

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.20 12:04:35