Receiving Insufficient Permission error from DirectoryService

前端 未结 4 1435
执笔经年
执笔经年 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:34

    Scopes

    It appears that you are trying this Quickstart:

    • .NET Quickstart for Directory API

    However, the scope(s) used in that tuturoial are:

    new [] { DirectoryService.Scope.AdminDirectoryUserReadonly };
    

    However, in the code your posted code you have:

    new[] { DirectoryService.Scope.AdminDirectoryOrgunit, DirectoryService.Scope.AdminDirectoryUser },
    

    Tokens

    After you change your scopes (shown above), you may have to delete your OAuth2 token, and then re-authorize access for your application. (Unless you haven't done the "authorize access" step yet.)

    \token.json\Google.Apis.Auth.OAuth2.Responses.TokenResponse-user
    

    Enable APIs

    Also, as I think you already discovered, enabling the Directory API is different process than enabling the Gmail API (and found at different URLs)

    Enable Directory API

    Enable Gmail API

提交回复
热议问题