0
SDK를 통해 Google 드라이브에서 문서 목록을 가져 오려고합니다. 서비스 계정을 사용하여 인증을 수행하고 전체 사용 권한이있는 https://www.googleapis.com/auth/drive 범위를 설정합니다.Google 드라이브 API로 파일을 나열 할 수 없습니다.
그러나 Google 드라이브에는 테스트 파일이 있지만 응답에는 빈 항목 목록이 포함되어 있습니다.
AuthorizationServerDescription desc = GoogleAuthenticationServer.Description;
X509Certificate2 key = new X509Certificate2(m_file, "notasecret", X509KeyStorageFlags.Exportable);
string scope = Google.Apis.Drive.v2.DriveService.Scopes.Drive.ToString().ToLower();
AssertionFlowClient client = new AssertionFlowClient(desc, key) { ServiceAccountId = m_email, Scope = "https://www.googleapis.com/auth/" + scope };
OAuth2Authenticator<AssertionFlowClient> auth = new OAuth2Authenticator<AssertionFlowClient>(client, AssertionFlowClient.GetState);
DriveService service = new DriveService(auth);
FilesResource.ListRequest request = service.Files.List();
request.Q = "";
Stream dataStream = request.FetchAsStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
감사 클라우디오을. 저는이 Google 드라이브 SDK의 초보자입니다. 내가 할 수없는 위임을 설정하려면 특정 도메인의 관리자 여야합니다. Google 드라이브에서 로컬 DB로 내 문서를 다운로드하는 서비스를 설정하고 싶다면 인증을 얻기위한 GUI가 없어야합니다. 어떤 제안? – asir6
앱을 승인하려면 적어도 한 번 이상 OAuth 플로우를 통과해야하지만 새로 고침 토큰을 영원히 저장하고 사용자 상호 작용없이 새로운 액세스 토큰을 생성하는 데 사용할 수 있습니다. https://developers.google.com/drive/about-auth –
감사합니다. 클라우디오. – asir6