Hello,
I'm using JSON approach for authenticating to DFP.
On 17 Aug, all of a sudden none of the Client's authentication is successful. I'm getting "OAuthException: Credential could not be refreshed" near .generateCredential()
But when I Googled out, I got a feeling this Exception will occur only when we use "ClientID and ClientSecret" approach and the "code" to generate refresh token or the current Refresh token is expired (I'm not sure, which one is the exact reason).
Credential oAuth2Credential = new OfflineCredentials.Builder()
.forApi(Api.DFP)
.fromFile()
.build()
.generateCredential(); // Exception occurred here
Below is the complete error.
Exception in thread "main" com.google.api.ads.common.lib.exception.OAuthException: Credential could not be refreshed.
at com.google.api.ads.common.lib.auth.OfflineCredentials.generateCredential(OfflineCredentials.java:178)
at dfp.axis.v201702.companyservice.GetAdvertisers.main(GetAdvertisers.java:85)
Caused by: com.google.api.client.auth.oauth2.TokenResponseException: 400 Bad Request
{
"error" : "invalid_grant",
"error_description" : "Invalid JWT: Token must be a short-lived token and in a reasonable timeframe"
}
at com.google.api.client.auth.oauth2.TokenResponseException.from(TokenResponseException.java:105)
at com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:287)
at com.google.api.client.auth.oauth2.TokenRequest.execute(TokenRequest.java:307)
at com.google.api.client.googleapis.auth.oauth2.GoogleCredential.executeRefreshToken(GoogleCredential.java:384)
at com.google.api.client.auth.oauth2.Credential.refreshToken(Credential.java:489)
at com.google.api.ads.common.lib.auth.OAuth2Helper.callRefreshToken(OAuth2Helper.java:69)
at com.google.api.ads.common.lib.auth.OfflineCredentials.generateCredential(OfflineCredentials.java:172)
... 1 more
Thank you.