0
votes

I have a service account with domain-wide delegation

I am building credentials with following code:

GoogleCredential.Builder()
                .setTransport(new NetHttpTransport())
                .setJsonFactory(new JacksonFactory())
                .setServiceAccountId(AppConfig.SERVICE_ACCOUNT_ID)
                .setServiceAccountPrivateKeyFromP12File(privateKey)
                .setServiceAccountScopes(Collections.singleton(DriveScopes.DRIVE_METADATA_READONLY))
                .setServiceAccountUser(user.getEmail())
                .build();

And getting Drive service like that:

Drive.Builder(
            new NetHttpTransport(),
            JacksonFactory.getDefaultInstance(), credential)
            .setApplicationName("drive-demo")
            .build();

Everything works smoothly when I have opened GDrive in browser. Browser tab is not connected to the app anyhow. When browser is closed and session expired - I can't fetch anything from the Drive. Credential token gets updated and I'm not getting any error or exception.

Is there any kind of 'access-type = offline' for domain-wide account? What did I miss?

1

1 Answers

0
votes

Looking at the Domain-Wide Delegation docs in Drive, it doesn't mention that this works offline.