1

I followed below steps to integrate Google Chat API in my project

  1. Created APP and enabled Google Chat API
  2. Created service account and stored private key file
  3. Code for getting credential and calling 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();

But getting error like :

Google.Apis.Requests.RequestError Invalid project number. [404]

0 Answers0