I have Problem when calling Gmail service to insert a MimeMessage
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(JSON_FACTORY)
.setServiceAccountId(accountId)
.setServiceAccountPrivateKeyFromP12File(new File(urlFile))
.setServiceAccountScopes(
Collections.singleton(GmailScopes.GMAIL_INSERT))
.setServiceAccountUser(accountUser).build();
Gmail service = new Gmail.Builder(httpTransport, JSON_FACTORY,
credential).build();
....
message = service.users().messages().insert(accountUser, message)
.setDeleted(Boolean.TRUE).execute();
I receive a 400 error :
com.google.api.client.auth.oauth2.TokenResponseException: 400 Bad Request { "error" : "invalid_grant", "error_description" : "java.security.SignatureException: Invalid signature for token:.... }