Google Ads API: Credentials failed to obtain metadata
I'm encountering an issue with the Google Ads API where I'm receiving the following error message:
Credentials failed to obtain metadata
This error occurs when making requests to the Google Ads API using the GoogleAdsService/Search method. Here's an example of the request and response details:
Request
MethodName: google.ads.googleads.v16.services.GoogleAdsService/Search Endpoint: googleads.googleapis.com:443 Headers: {developer-token=REDACTED, login-customer-id=9854212609, x-goog-api-client=gl-java/17.0.10__Oracle-Corporation gccl/31.0.0 gapic/31.0.0 gax/2.47.0 grpc/1.62.2} Body: customer_id: "9854212609" query: "SELECT campaign.id, campaign.name FROM campaign"
Response
Headers: null Body: null Failure message: null Status: Status{code=UNAVAILABLE, description=Credentials failed to obtain metadata, cause=com.google.auth.oauth2.GoogleAuthException: com.google.api.client.http.HttpResponseException: 401 Unauthorized POST https://oauth2.googleapis.com/token
...
Here are the details of my configuration:
- I'm using Spring Boot for my application.
- I have a google-ads.properties file where I've configured the necessary credentials such as clientId, clientSecret, refreshToken, developerToken, and loginCustomerId.
- I've implemented the Google Ads client using the GoogleAdsClient class provided by the Google Ads Java library.
- I've verified that the credentials are correct and have the necessary permissions to access the Google Ads API.
Despite these configurations, I'm still encountering the error mentioned above. I'm not sure what could be causing the issue. Any insights or suggestions on how to troubleshoot and resolve this would be greatly appreciated.
Thank you in advance for your help!
based on the provided error message and the details of the configuration, I expected the Google Ads API requests to authenticate successfully and return the requested data. However, the actual result was a failure with the message "Credentials failed to obtain metadata," indicating an authentication issue.