无法通过Java设置Adwods API,在最后一步中发出多个错误

时间:2018-02-08 09:20:32

标签: adwords-apiv201402 adwords-api-v201109

我正在尝试通过Java设置Adwords API,所有步骤都很顺利,但在运行GetCampaigns.java的最后一步,它给出了几个错误

  

“线程中的异常”主题“com.google.api.ads.common.lib.exception.OAuth异常:无法刷新凭据。在com.google.api.ads.common.lib.auth.OfflineCredentials.generateCredential (OfflineCredentials.java:240)at adwords.axis.v201705.basicoperations.GetCampaigns.main(GetCampaigns.java:46)引起:com.google.api.client.auth.oauth2.TokenResponseException:400 Bad Request {“error” :com_google.api.client.auth.oauth2.TokenResponseException.from(TokenResponseException.java:105)中的com_google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:287)中的“invalid_grant”} )com.google.api.client.auth.oauth2.TokenRequest.execute(TokenRequest.java:307)at com.google.api.client.auth.oauth2.Credential.executeRefreshToken(Credential.java:570)at com。 go.com.api.client.googleapis.auth.oauth2.GoogleCredential.executeRefreshToken(GoogleCredential.java:362)at com.google.api.client.auth.oauth2.Credential.refreshToken(Credential.java:489)在com.google.api.ads.common.lib.auth.OAuth2Helper.callRefreshToken(OAuth2Helper.java:69)com.google.api.ads.common.lib.auth.OfflineCredentials.generateCredential(OfflineCredentials.java:234) ......还有1个“

在此错误消息之后,它不会通过。

1 个答案:

答案 0 :(得分:1)

这看起来像是刷新令牌的问题。您是否生成了刷新令牌?

我通常运行此文件以生成刷新令牌。

https://github.com/googleads/googleads-java-lib/blob/master/examples/adwords_axis/src/main/java/adwords/axis/auth/GetRefreshToken.java

您是否将刷新令牌复制到ads.properties文件中?