2

I created a project using maven and followed the steps. But when i run the code i get the following error.

Exception in thread "main" java.lang.IllegalArgumentException
    at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkArgument(Preconditions.java:76)
    at com.google.api.client.util.Preconditions.checkArgument(Preconditions.java:37)
    at com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets.getDetails(GoogleClientSecrets.java:80)
    at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow$Builder.<init>(GoogleAuthorizationCodeFlow.java:195)
    at com.vertoanalytics.external.mailfetcher.GmailApiQuickstart.main(GmailApiQuickstart.java:41)

When I google it there are some ides about not having latest packges can cause this problem. Here is my meven dependency list related to the project

<dependency>
    <groupId>com.google.api-client</groupId>
    <artifactId>google-api-client</artifactId>
    <version>1.18.0-rc</version>
</dependency>
<dependency>
    <groupId>com.google.oauth-client</groupId>
    <artifactId>google-oauth-client</artifactId>
    <version>1.19.0</version>
</dependency>

<dependency>
    <groupId>com.google.apis</groupId>
    <artifactId>google-api-services-gmail</artifactId>
    <version>v1-rev7-1.19.0</version>
</dependency>
<dependency>
    <groupId>com.google.http-client</groupId>
    <artifactId>google-http-client-jackson</artifactId>
    <version>1.18.0-rc</version>
</dependency>

do i miss anything ?

dinesh707
  • 12,106
  • 22
  • 84
  • 134
  • You must copy the source code of `GmailApiQuickstart`, otherwise we won't be able to help you. – David Aug 26 '14 at 11:49
  • Its exactly same as : https://developers.google.com/gmail/api/quickstart/quickstart-java (section 3): but I assume that the problem is with some conflict where it rtys to load "com.google.api.client.repackaged.com.google.common.base.Preconditions" when the caller asks for "com.google.common.base.Preconditions" – dinesh707 Aug 26 '14 at 12:03
  • Can you make sure that the `client_secret.json` file exists ? It looks like the `clientSecrets` variable is null. – David Aug 27 '14 at 01:44
  • When I enter a wrong json file name then i get a FileNotFoundException. So the file is correctly placed in order to get the error in question. The json contains private_key_id, private_key, client_email, client_id. And the private key starts with "-----BEGIN PRIVATE KEY-----\n" and ends with "-----END PRIVATE KEY-----\n" – dinesh707 Aug 27 '14 at 06:18
  • Looks like an oauth issue to me, is jackson-core-asl being added, I believe its required. also there is a later version of google-api-services-gmail though I doubt that's the issue. – Arthur Thompson Sep 09 '14 at 17:24
  • I started using JavaMail, which is far easier to work with. Thnx – dinesh707 Sep 10 '14 at 07:02

0 Answers0