2013-07-17 2 views
1

서비스 계정이있는 파일을 얻으려면 아래 코드를 사용하고 있습니다. 직접 메시지를 전송하거나 응답을 얻으면서 여기Google 드라이브 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 @ 언급 한 설정을 기반으로 : 나는 서비스 계정

+0

https://developers.google.com/drive/delegation에서 설명한 위임을 진행 했습니까? –

+0

고마워 Burcu, 시작합니다 .... 새로운 Google APP 계정을 만들었고 @ https://developers.google.com/drive/delegation?hl=ko라는 설정을 언급했습니다.하지만 생각해 봅니다. 효과를 발휘할 시간 ....-) – Jeevan

+0

이제는 제대로 작동하는 것이 좋습니다. –

답변

0

저도 같은 문제가되었다 기반으로의 cPanel에서 적절한 설정이 있습니다. 나는 그것을 결국 작동시켰다. 나는 몇 가지 잘못을 저질렀다.

  1. 나는 Google Cloud Console에 가서 키 파일을 다시 생성하고 다운로드했습니다. API & auth-> Registered Apps로 이동하십시오.
  2. provider 개체에 입력 한 속성은 .ServiceAccountId.Scope입니다.
  3. Scope을 실제 범위로 바꾸고 열거 형 값을 사용하지 않아야했습니다 (이것은 VB를 사용하기 때문에 단지 문제입니다). VB.NET에서 GetStringValue() 열거 형 함수를 사용하지 않기 때문에 퓨전 테이블에서 작업 중이며 범위는 "퓨전 테이블"로 렌더링되었습니다. 이제 "https://www.googleapis.com/auth/fusiontables"을 사용하고 있습니다. 유효한 범위 목록은 here으로 이동하십시오.
  4. ServiceAccountId의 경우 서비스 계정 "이메일 주소 :"와 "@"를 사용했습니다. ([email protected])이며 콘솔 (12345.apps.googleusercontent.com)에 "클라이언트 ID :"로 표시되는 것은 아닙니다.

다른 사람들에게 도움이되기를 바랍니다.

관련 문제