GetRefrechToken.java can't get refresh token, exception occurs

208 views
Skip to first unread message

ringzw...@gmail.com

unread,
Jul 16, 2015, 11:19:45 AM7/16/15
to adwor...@googlegroups.com
I tried to setup the OAuth v2 authentiacation for Adworks API, following the instruction from Developer Console(https://developers.google.com/console/help/new/?hl=en_US#generatingoauth2).

I got the client ID and secret as installed app, save the information in ads.properties, then run GetRefrechToken.java. The following information is displayed in the console


I follow the URL and copy the code from the browser, then the following exceptions are raised:

Exception in thread "main" java.net.UnknownHostException: accounts.google.com
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:618)
at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:275)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:932)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1091)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250)
at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:77)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:972)
at com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:283)
at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeTokenRequest.execute(GoogleAuthorizationCodeTokenRequest.java:158)
at adwords.axis.auth.GetRefreshToken.getOAuth2Credential(GetRefreshToken.java:81)
at adwords.axis.auth.GetRefreshToken.main(GetRefreshToken.java:117)

Any tips on what goes wrong? Is it related to the configuration?

Umesh Dengale

unread,
Jul 16, 2015, 11:51:58 AM7/16/15
to adwor...@googlegroups.com, ringzw...@gmail.com
Hello,

Please check out the AdWords API OAuth2 guide and verify your client id and client secret key are generated as described in the guide. To learn more about how to request refresh tokens, please read the Access and refresh token guide.

Thanks,
Umesh, AdWords API Team.
Reply all
Reply to author
Forward
0 new messages