0

SDKを介してGoogleドライブからドキュメントのリストを取得しようとしています。サービスアカウントを使用して認証を実行し、スコープをhttps://www.googleapis.com/auth/driveに設定します。これは完全な権限を持っています。

ただし、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();
4

1 に答える 1

2

問題の詳細については、GoogleドライブSDKに対するNivcoの回答を確認してください。ドライブから返されたファイルの空の配列。

基本的に、ファイルはサービスアカウントのドライブにリストされており、自分のドライブにはリストされていません。偽装しようとしているドメインのユーザーのメールを設定する必要があります。GoogleドライブSDKのドキュメントで、その方法を示す手順とサンプルコードを確認してください。

https://developers.google.com/drive/delegation

于 2012-11-23T07:45:32.830 に答える