Hello,

The best way to debug this kind of issue is to actually capture the network 
traffic or log the HTTP headers as you're making the call, to see whether 
or not you're actually successfully creating an access token. In the code 
you provided, you're using a non-recommended method of handling 
authentication. The Python client library can handle authentication for 
you, if you put your client id, client secret, and refresh token in a yaml 
file with standard format and just allow the client to read it. 
Alternatively, you can pass them to the client on initialization as a yaml 
string if you don't want to commit it to disk. See this example 
file: 
https://github.com/googleads/googleads-python-lib/blob/master/googleads.yaml

If you must pass your own oauth2 credentials to the class constructor, it 
must be a googleads.oauth2.GoogleOAuth2Client, which is another class that 
is part of the Python client library. I can't see the context in your code 
to see if you're using the right class or not, but I believe this may be 
the root cause of the issue.

Overall, I recommend doing your authentication by simply filling out the 
.yaml file and putting it in your home directory, and let the client 
library handle the implementation details.

Regards,
Mike, AdWords API Team

On Sunday, September 30, 2018 at 11:45:55 PM UTC-4, Dannison Yao (AdWords 
API Team) wrote:
>
> Hi Nikhil,
>
> My apologies for the delayed response. To answer your concern in this 
> thread 
> <https://groups.google.com/d/msgid/adwords-api/402684c3-4c39-4a05-9278-8bd0b091d425%40googlegroups.com>,
>  
> if you are making calls against your production account, then yes, the OAuth2 
> Credentials 
> <https://developers.google.com/adwords/api/docs/guides/authentication> has 
> to be setup by the same email used in your production MCC account. 
>
> Based on your logs, it seems that the credentials are not detected by the 
> API. Could you confirm if you have inputted your OAuth2 Credentials and 
> other information in the yaml file? If not, kindly input the credentials in 
> their respective fields in the yaml file then you may try to call the 
> service again.
>
> If this still does not work, could you provide the complete SOAP request 
> and response logs that were generated so that I could investigate this 
> further? You may provide complete the logs via *Reply privately to author*
> .
>
> Regards,
> Dannison
> AdWords API Team
>
> On Saturday, September 29, 2018 at 4:12:36 AM UTC+8, nikhil almeida wrote:
>>
>> I have tried configuring the yaml file and getting the constructor by 
>> loading from storage while also the method below.
>> But I keep getting the following error. Can some one please help?
>>
>> [2018-09-27 17:02:52,326 - googleads.soap - WARNING] Error summary: 
>> {'faultMessage': "[AuthenticationError.OAUTH_TOKEN_INVALID @ ; 
>> trigger:'<null>']", 'requestId': '000576e32d3d31000aa37e521e0075d1', 
>> 'serviceName': 'CustomerService', 'methodName': 'getCustomers', 
>> 'operations': '0', 'responseTime': '20'}
>>
>> ....
>>
>>
>> GoogleAdsServerFault: [AuthenticationError.OAUTH_TOKEN_INVALID @ ; 
>> trigger:'<null>'] 
>>
>>
>>
>>
>> GOOGLE_OAUTH2_ENDPOINT = 'https://accounts.google.com/o/oauth2/token'
>>
>> # OAuth2 credential information.
>> DEFAULT_CLIENT_ID = 'INSERT_CLIENT_ID_HERE'
>> DEFAULT_CLIENT_SECRET = 'INSERT_CLIENT_SECRET_HERE'
>> DEFAULT_REFRESH_TOKEN = 'INSERT_REFRESH_TOKEN_HERE'
>> # AdWords API information.
>> DEFAULT_CLIENT_CUSTOMER_ID = 'INSERT_CLIENT_CUSTOMER_ID_HERE'
>> DEFAULT_DEVELOPER_TOKEN = 'INSERT_DEVELOPER_TOKEN_HERE'
>> USER_AGENT = 'INSERT_USER_AGENT_HERE'
>>
>> oauth2credentials = client.OAuth2Credentials(
>>       None, DEFAULT_CLIENT_ID, DEFAULT_CLIENT_SECRET, 
>> DEFAULT_REFRESH_TOKEN,
>>       datetime.datetime(1980, 1, 1, 12), GOOGLE_OAUTH2_ENDPOINT,
>>       USER_AGENT)
>>
>> oauth2credentials.refresh(httplib2.Http())
>>
>> oauth2_client = 
>> oauth2.GoogleAccessTokenClient(oauth2credentials.access_token, 
>> oauth2credentials.token_expiry)
>>
>>
>> adwords_client = adwords.AdWordsClient(
>>   DEFAULT_DEVELOPER_TOKEN, oauth2_client, USER_AGENT,
>>   client_customer_id=DEFAULT_CLIENT_CUSTOMER_ID)
>>
>> customer = adwords_client.GetService('CustomerService').getCustomers()[0]
>> print(f"You are logged in as {customer['customerId']}")
>>
>>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
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 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/14684871-658f-4e01-a56a-5da4ae6135d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • ... nikhil almeida
    • ... 'Dannison Yao (AdWords API Team)' via AdWords API and Google Ads API Forum
      • ... 'Michael Cloonan (AdWords API Team)' via AdWords API and Google Ads API Forum
        • ... nikhil almeida
      • ... nikhil almeida

Reply via email to