1
我正在使用下面的一段代碼來獲取帶有服務帳戶的文件。Google Drive API 1.4錯誤:發送直接消息或獲取響應時出錯
var certificate = new X509Certificate2("D:\\05-privatekey.p12", "notasecret", X509KeyStorageFlags.Exportable);
var privateKey = certificate.Export(X509ContentType.Cert);
var provider = new AssertionFlowClient(GoogleAuthenticationServer.Description, certificate)
{
ServiceAccountId = "[email protected]account.com",
Scope = DriveService.Scopes.Drive.GetStringValue(),
ServiceAccountUser = "[email protected]"
};
var auth = new OAuth2Authenticator<AssertionFlowClient>(provider, AssertionFlowClient.GetState);
DriveService service = new DriveService(new BaseClientService.Initializer()
{
Authenticator = auth,
ApplicationName = "My APP",
});
FilesResource.ListRequest request = service.Files.List();
FileList files = request.Execute();
這裏執行()API是給異常
錯誤在發送直接消息或獲取 響應發生。
編輯:項目是基於提到@https://code.google.com/p/google-api-dotnet-client/wiki/Build
編輯2的設置:我有一個基於服務帳戶
您是否瀏覽了https://developers.google.com/drive/delegation上介紹的代表團? –
感謝Burcu, 它開始工作.... 我創建了一個新的Google APP帳戶,並提到了@ https://developers.google.com/drive/delegation設置。但我認爲它需要一些時間生效.... :-) – Jeevan
很高興知道它現在工作。 –