[SHOPPING] java.lang.IllegalArgumentException: Please use the Builder and call setJsonFactory, setTransport and setClientSecrets

160 views
Skip to first unread message

rafa....@rocketroi.com

unread,
Jan 23, 2017, 7:48:06 AM1/23/17
to AdWords API Forum
I'm getting that error 

java.lang.IllegalArgumentException: Please use the Builder and call setJsonFactory, setTransport and setClientSecrets

trying to execute the following line:

credential.setRefreshToken(token.getRefreshToken())

It's very weird because the 'setRefreshToken' method is waiting for a String and the 'token.getRefreshToken()' is returning a String.

Credential class if form package: com.google.api.client.auth.oauth2, and 'token' it's a custom object taht contains all the data related to Shopping access token and refresh token. The token object is arriving full of data (not null or with empty data)


Vishal Vinayak (Adwords API Team)

unread,
Jan 23, 2017, 12:17:23 PM1/23/17
to AdWords API Forum
Hi Rafa,

If you are trying to create an AdWords session without the properties file, you can refer to this example. You can use the withRefreshToken() predicate to specify the refresh token as follows:

Credential credential = new OfflineCredentials.Builder() 
                                   .forApi(Api.ADWORDS) 
                                   .withClientSecrets(clientId, clientSecret) 
                                   .withRefreshToken(refreshToken) 
                                   .build() 
                                   .generateCredential();

Please revert if you have additional questions. 

Regards,
Vishal, AdWords API Team
Reply all
Reply to author
Forward
0 new messages