我正在尝试设置服务帐户和域范围的权限。我已经成功创建了服务帐户,并且还委派了整个域的权限。
使用代码,我可以使用我们域用户的日历或邮件,但不能使用驱动器。
我正在运行以下代码:
public static readonly string[] REQUIRED_PERMISSIONS =
{
CalendarService.Scope.Calendar,
"https://www.google.com/m8/feeds/contacts",
TasksService.Scope.Tasks,
DriveService.Scope.Drive,
DriveService.Scope.DriveAppsReadonly,
DriveService.Scope.DriveFile,
DriveService.Scope.DriveAppdata,
DriveService.Scope.DriveMetadataReadonly,
DriveService.Scope.DriveReadonly,
GmailService.Scope.MailGoogleCom
};
var cred = new ServiceAccountCredential(new ServiceAccountCredential.Initializer("user.iam.gserviceaccount.com")
{
Scopes = REQUIRED_PERMISSIONS,
User = "test@domain"
}.FromPrivateKey(@"privatekey"));
var mailService = new GmailService(new BaseClientService.Initializer()
{
HttpClientInitializer = cred,
ApplicationName = ApplicationName,
});
var result = mailService.Users.GetProfile("me");
var resultFetch = result.Execute();
我收到错误Google.Apis.Auth.OAuth2.Responses.TokenResponseException: 'Error:"unauthorized_client", Description:"Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested.", Uri:""'
[我知道我正在使用GMail请求,但这只是为了稍后在驱动器请求上使用“测试连接”]]
当我删除与Drive相关的示波器时,所有的示波器都在工作-但这不是解决方案。
我有:
我也尝试过以下问题:Access Domain wide Google Drive data with ServiceAccount Actor userFailure of delegation of Google Drive access to a service account
我正在尝试设置服务帐户和域范围的权限。我已经成功创建了服务帐户,并且还委派了整个域的权限。我已经为...
您的问题是由于您使用过多的scope