Let me explain all my steps.
1. I've created service account in my project in 
https://console.cloud.google.com/.
2. I've created key and get creds from json file.
3. My admin configure domain wide delegation for this service account, 
scope https://www.googleapis.com/auth/adwords
4. I have a user email which has access to google ads account, I granted 
him permissions in the service account as Service Account User.
5. I've created ServiceAccountCredentials in my code and use there creds 
from step 2 and user from step 4 as serviceAccountUser.
6. When it tries to refresh access token I get 
com.google.api.client.http.HttpResponseException: 401 Unauthorized
POST https://oauth2.googleapis.com/token

What I'm missing?
On Monday, October 3, 2022 at 8:20:51 PM UTC+2 adsapi wrote:

> Hi Kate,
>
> Thanks for reaching out to the Google Ads API Forum.
>
> If you have used an impersonated email as *@*****.iam.gserviceaccount.com 
> <http://iam.gserviceaccount.com>*, then note that service account 
> authentication will not work.  Kindly note that impersonated_email 
> (formerly delegate_account) is an account email used as a delegate. In this 
> case, you have to provide the email of a user that has access to the Google 
> Ads account and grant impersonation abilities in the G Suite domain for 
> this scope: *https://www.googleapis.com/auth/adwords* 
> <https://www.googleapis.com/auth/adwords>. 
>
> This is used for authenticating using a service account. For more 
> information, you may see *OAuth2 Service Account documentation* 
> <https://developers.google.com/google-ads/api/docs/client-libs/python/oauth-service>
> .
>
> In addition, service account authentication requires a *Google Workspace* 
> <https://workspace.google.com/> domain and a service account that was 
> granted domain-wide delegation access by a super administrator for the 
> domain. You may retry your request with workspace domain and valid 
> impersonated_email, and let us know the results.
>
> If it still doesn't work, then could you please confirm if you already 
> followed this *service account* 
> <https://developers.google.com/google-ads/api/docs/oauth/service-accounts> 
> document and completed all mentioned *requirements* 
> <https://developers.google.com/google-ads/api/docs/oauth/service-accounts#prerequisites>
>  
> for the service account authentication? If not, then you refer to it.
>
> If you’re encountering API error after following the above guide, you may 
> provide the complete *request* 
> <https://developers.google.com/google-ads/api/docs/concepts/field-service#request>
>  
> and *response* 
> <https://developers.google.com/google-ads/api/docs/concepts/field-service#response>
>  
> logs with *request ID* 
> <https://developers.google.com/google-ads/api/docs/concepts/call-structure#request-id>
>  
> generated via reply privately to author option, as seen in the respective 
> links, so that our team can check better.
>
> For you to enable complete logs on your end for the client library, 
> logging can be enabled by navigating to the Client libraries > Your client 
> library (ex Python) > Logging documentation, which you can access from this 
> *link* <https://developers.google.com/google-ads/api/docs/client-libs>. 
>
> Regards,
> [image: Google Logo] 
> Yasar 
> Google Ads API Team 
>   
>
> ref:_00D1U1174p._5004Q2ewSHl:ref
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/3aaf4d08-cdb4-47e4-9b62-619cc4560e72n%40googlegroups.com.
  • Se... 'Kate Orlova' via Google Ads API and AdWords API Forum
    • ... 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum
      • ... 'Kate Orlova' via Google Ads API and AdWords API Forum

Reply via email to