如何准确设置客户端ID和访问群体以验证Android应用程序的Google云端点

如何准确设置客户端ID和访问群体以验证Android应用程序的Google云端点,android,google-cloud-endpoints,Android,Google Cloud Endpoints,在endpoints应用程序引擎后端中,如何准确设置 @Api(name=... clientIds = {what-goes-here-exactly-1}, audiences = {what-goes-here-exactly-2} ) credential = GoogleAccountCredential.usingAudience(this, what-goes-here-exactly-3); 在Android客户端中,我应该如何设置

在endpoints应用程序引擎后端中,如何准确设置

@Api(name=...
     clientIds = {what-goes-here-exactly-1},
     audiences = {what-goes-here-exactly-2}
)
credential = GoogleAccountCredential.usingAudience(this,
           what-goes-here-exactly-3);
在Android客户端中,我应该如何设置

@Api(name=...
     clientIds = {what-goes-here-exactly-1},
     audiences = {what-goes-here-exactly-2}
)
credential = GoogleAccountCredential.usingAudience(this,
           what-goes-here-exactly-3);
此处和此处的说明相互冲突/混乱/不清楚

我已经在API控制台的API访问中生成了很多键,但不确定如何使用它们,以及如何在上面的语句中附加/前置它们


谢谢。

在您的后端,您将包括:

@Api(
  name = "myapi",
  version = "v1",
  clientIds = {Ids.WEB_CLIENT_ID, Ids.ANDROID_CLIENT_ID},
  audiences = {Ids.ANDROID_AUDIENCE}
)
其中,这些常量的定义如下:

public class Ids {
  public static final String WEB_CLIENT_ID = "12345.apps.googleusercontent.com";
  public static final String ANDROID_CLIENT_ID = "12345-abc.apps.googleusercontent.com";
  public static final String ANDROID_AUDIENCE = WEB_CLIENT_ID;
}
使用上述值,您将在Android代码中使用的代码为:

credential = GoogleAccountCredential.usingAudience(this,
    "server:client_id:" + Ids.ANDROID_AUDIENCE);

谢谢你,丹。在您的答案中使用Audience(即“server:client\u id:”+Ids.WEB\u client\u id)来表示credential=GoogleAccountCredential。你能更新吗?我认为这解决了我的问题,但我仍然有一点困难,让它在本地开发服务器模式下工作,然后我会接受答案。为了让它更容易理解,它实际上是ANDROID_用户,他们只是碰巧是等价的。