2016-08-08 10 views
0

웹 응용 프로그램에서 Google 드라이브에 파일을 업로드해야합니다. 서비스 계정 인증을 사용해야합니다. Google 드라이브 가이드 (DotNetQuickStart)와이 자습서 (인증 Authentication Google Drive MVC)를 읽었지만 수행해야 할 작업을 모릅니다.Google 드라이브에 파일을 업로드하는 서비스 계정 인증

Google 드라이브 가이드를 사용하려면 매개 변수를 Google 개발자 페이지로 설정해야합니다.

나는 내 프로젝트에 다운로드 및 구현 secret.json 파일이 있고 난 내 프로젝트에 코드를 추가해야 :

public static Google.Apis.Drive.v2.Data.File uploadFile(string _uploadFile, string _parent) 
    { 
     string[] scopes = new string[] { DriveService.Scope.Drive }; // Full access 

     var keyFilePath = @"c:\file.p12"; // Downloaded from https://console.developers.google.com 
     var serviceAccountEmail = "[email protected]"; // found https://console.developers.google.com 

     //loading the Key file 
     var certificate = new X509Certificate2(keyFilePath, "notasecret", X509KeyStorageFlags.Exportable); 
     var credential = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(serviceAccountEmail) 
     { 
      Scopes = scopes 
     }.FromCertificate(certificate)); 

하지만 keyFilePath 및 serviceAccountEmail에 설정하는 것을 이해할 수 없다. 어떻게 내가이 코드를 설정 대신 secret.json의 https://console.developers.google.com/iam-admin/serviceaccounts

이동하여 P12 키 파일이 필요합니다 모든

+0

열기 아래의 비밀 JSON 파일들이 그에있는 경우 나는 그들이 켜져 있어야 현명한 다른 기억하지 못할 볼 볼 수 있습니다 Google Developers 콘솔의 프로젝트 내가 아는 한 Google .Net 클라이언트 라이브러리는 여전히이를 지원하지 않습니다. 나는 그것을 조사해야한다. – DaImTo

답변

0

덕분에 -> 프로젝트를 선택 ->에있는 3 개 세로 점을 클릭 나열된 서비스 계정의 오른쪽 -> 키를 생성 -> 당신이 대화

enter image description here

관련 문제