0

我按照以下步骤将 Google Chat API 集成到我的项目中

  1. 创建 APP 并启用 Google Chat API
  2. 创建服务帐户并存储私钥文件
  3. 获取凭证和调用 API 的代码
    ServiceAccountCredential credential;
    string[] Scopes = { "https://www.googleapis.com/auth/chat.bot" };
    using (Stream stream = new FileStream(jsonfile, FileMode.Open, FileAccess.Read, 
    FileShare.Read))
    {
    credential = (ServiceAccountCredential)
    GoogleCredential.FromStream(stream).CreateScoped(Scopes)// Gathers scopes requested  
    .CreateWithUser("abc@xyz.com").UnderlyingCredential;
    }
    var service = new HangoutsChatService(new BaseClientService.Initializer()
    {
    HttpClientInitializer = credential,
    ApplicationName = "GoogleChatDemoApp",
    });
    ListSpacesResponse spaceList = service.Spaces.List().Execute();

但出现错误,如:

Google.Apis.Requests.RequestError 项目编号无效。[404]

4

0 回答 0