javaee-esprit / google-api-java-client

Automatically exported from code.google.com/p/google-api-java-client
0 stars 0 forks source link

wiki : Update code example needed for OAuth2#Service_Accounts #883

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
google-api-java-client : 1.18.0-rc

The example code at this place must be updated : 
https://code.google.com/p/google-api-java-client/wiki/OAuth2#Service_Accounts

With the old API the code was :
GoogleCredential credential = new 
GoogleCredential.Builder().setTransport(HTTP_TRANSPORT)
            .setJsonFactory(JSON_FACTORY)
            .setServiceAccountId("[[INSERT SERVICE ACCOUNT EMAIL HERE]]")
            .setServiceAccountScopes(PlusScopes.PLUS_ME)
            .setServiceAccountPrivateKeyFromP12File(new File("key.p12"))
            // .setServiceAccountUser("user@example.com")
            .build();

But now, he must like :
private static final List<String> SCOPES = Arrays.asList(
              PlusScopes.PLUS_ME);    
GoogleCredential credential = new 
GoogleCredential.Builder().setTransport(HTTP_TRANSPORT)
            .setJsonFactory(JSON_FACTORY)
            .setServiceAccountId("[[INSERT SERVICE ACCOUNT EMAIL HERE]]")
            .setServiceAccountScopes(SCOPES)
            .setServiceAccountPrivateKeyFromP12File(new File("key.p12"))
            // .setServiceAccountUser("user@example.com")
            .build();

Original issue reported on code.google.com by sebastie...@progis.fr on 5 Jun 2014 at 9:38

GoogleCodeExporter commented 9 years ago

Original comment by wonder...@google.com on 5 Jun 2014 at 5:00

GoogleCodeExporter commented 9 years ago

Original comment by wonder...@google.com on 12 Jun 2014 at 5:41

GoogleCodeExporter commented 9 years ago

Original comment by wonder...@google.com on 24 Jul 2014 at 6:47