1
서비스 계정이있는 .NET client API으로 Google 드라이브에 파일을 생성합니다. 모든 도메인에Google 드라이브 API (.NET) - 서비스 계정에서 도메인 사용자로 소유권 이전
string[] scopes = new string[] { DriveService.Scope.Drive };
GoogleCredential credential;
using (var stream = new FileStream(Directory.GetCurrentDirectory() + "/Resources/GoogleCredentials.json", FileMode.Open, FileAccess.Read))
{
credential = GoogleCredential.FromStream(stream).CreateScoped(scopes);
}
DriveService drive = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
});
내가 성공적으로 파일을 생성,
var f = drive.Files;
var request = f.Create(new Google.Apis.Drive.v3.Data.File()
{
Name = "Test from ASP.NET Core",
AppProperties = prop,
MimeType = "application/vnd.google-apps.document"
});
var file = await request.ExecuteAsync();
는 주를,하지만 난 도메인 사용자에게 소유권을 이전 할 수 없다.
Permission permission = new Permission()
{
EmailAddress = "[email protected]",
Type = "user",
Domain = "example.com",
Role = "owner"
};
var requestpermission = drive.Permissions.Create(permission, file.Id);
requestpermission.TransferOwnership = true;
var perm = await requestpermission.ExecuteAsync();
나는 오류 얻을 :
내가 this link을 발견,하지만 P12의 인증서 파일을 사용하지 않는 것이 좋습니다. 그래서 JSON을 사용하고 싶습니다.The specified domain is invalid or not applicable for the given permission type.