Receiving Insufficient Permission error from DirectoryService

前端 未结 4 1473
执笔经年
执笔经年 2021-01-12 08:00

I am trying to setup c# code to manage our Google domain.

I am receiving this error whenever I call service.Users.List() or any other method from the DirectoryServic

4条回答
  •  甜味超标
    2021-01-12 08:28

    Here is my working credentials code:

    using (var stream =
        new FileStream("client_secret.json", FileMode.Open, FileAccess.Read))
        {
            string credPath = System.Environment.GetFolderPath(
                System.Environment.SpecialFolder.Personal);
                credPath = Path.Combine(credPath, ".credentials/calendar-dotnet-quickstart.json");
    
                UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets,
                    new string[] { CalendarService.Scope.Calendar },
                    "username@gmail.com",
                    CancellationToken.None,
                    new FileDataStore(credPath, true)).Result;
                Console.WriteLine("Credential file saved to: " + credPath);
            }
    

    Make sure to Enable the API in the Console,

提交回复
热议问题