Previously we are using https://apps-apis.google.com/a/feeds/emailsettings/2.0 following approach to manage SendAs GET and SET.
gmailFilterService = new GmailFilterService(this.applicationName);
gmailFilterService.setOAuthCredentials(oauthParameters, signer);
gmailFilterService.setReadTimeout(Lxxx.readTimeout);
gmailFilterService.useSsl();
How can we use this with oauth2 with service account
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(jsonFactory)
.setServiceAccountId(serviceAccountEmail)
.setServiceAccountScopes(Arrays.asList(DirectoryScopes.ADMIN_DIRECTORY_USER , DirectoryScopes.ADMIN_DIRECTORY_ORGUNIT))
.setServiceAccountUser(adminEmail)
.setServiceAccountPrivateKeyFromP12File(
new java.io.File(serviceAccountPKCS12FilePath))
.build();