0

I have below piece of code to read documents from domain users Drive. One of the user in selected Domain is suspended. I am getting 'Precondition failed.' error for this suspended users. For all other users same code works properly. Is it possible to read the contents of suspended Google users Drive by using Admin APIs.

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 = "877564787679-glrhdp0e4998dkc6mfj62@developer.gserviceaccount.com",
        Scope = DriveService.Scopes.Drive.GetStringValue(),
        ServiceAccountUser = "suspendedusersEmailAddress"
    };
    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();
Jeevan
  • 167
  • 2
  • 11

2 Answers2

0

No, you'll script will need to unsuspend the user before attempting to access their Google Drive. Also be aware that immediately after issuing the users.patch(suspended=false), there may be a delay of up to an hour before the Google Drive becomes accessible via the Service Account. You'll need to test for this delay.

After accessing the Google Drive, you can re-suspend the user.

Jay Lee
  • 13,415
  • 3
  • 28
  • 59
0

The previous Google document list API seems to have an option to get the files of suspended users. Not sure though why the current drive SDK does not seem to have such an option.

https://developers.google.com/google-apps/documents-list/?hl=ja Section: Using Google Apps administrative access to impersonate other domain users

Yuvaraj N
  • 1
  • 1