NameError: name 'client' is not defined

1,103 views
Skip to first unread message

Mohamed Eshra

unread,
Sep 28, 2020, 6:15:57 PM9/28/20
to Google's DoubleClick Campaign Manager API Forum
Hello,

How can I solve this error, please?
"NameError: name 'client' is not defined"

I get the error when I try to report through DCM's API using the following Python code to make a request:
# Set up a Flow object to be used if we need to authenticate.
flow = client.flow_from_clientsecrets(
    path_to_client_secrets_file, scope=OAUTH_SCOPES)

# Check whether credentials exist in the credential store. Using a credential
# store allows auth credentials to be cached, so they survive multiple runs
# of the application. This avoids prompting the user for authorization every
# time the access token expires, by remembering the refresh token.
storage = Storage(CREDENTIAL_STORE_FILE)
credentials = storage.get()

# If no credentials were found, go through the authorization process and
# persist credentials to the credential store.
if credentials is None or credentials.invalid:
  credentials = tools.run_flow(flow, storage,
                               tools.argparser.parse_known_args()[0])

# Use the credentials to authorize an httplib2.Http instance.
http = credentials.authorize(httplib2.Http()) 

Thank you!

Looking forward to your confirmation.

Regards,
Eshra

DCM API (DoubleClick Campaign Mgr)

unread,
Sep 29, 2020, 1:54:43 AM9/29/20
to mohamed.a...@gmail.com, google-doubleclick-...@googlegroups.com
Hi Eshra,

Thank you for reaching out to us.

Could you please provide the following details via Reply privately to author option, for us to assist you further?
  • DCM Account ID
  • Profile ID
  • Report ID in question
  • Request body and API response in JSON format
Could you try our API explorer as well, then let me know how it goes?

Regards,
Google Logo
Teejay Wennie Pimentel
DCM API Team
 



 

ref:_00D1U1174p._5004Q25Xb5m:ref

Mohamed Eshra

unread,
Sep 30, 2020, 6:25:59 PM9/30/20
to Google's DoubleClick Campaign Manager API Forum
Hi Teejay,

Is there any other way please that I can share the information privately with you?

I'm currently getting an error when trying to share with you privately.


Thank you.

Looking forward to your reply.

Regards,
Eshra

DCM API (DoubleClick Campaign Mgr)

unread,
Oct 1, 2020, 12:54:22 AM10/1/20
to mohamed.a...@gmail.com, google-doubleclick-...@googlegroups.com
Hi Mohamed,

Could you kindly send the requested details to dcmapi-...@google.com instead? Please notify us here once the details has been sent the the given email address.

Mohamed Eshra

unread,
Oct 1, 2020, 5:38:12 AM10/1/20
to Google's DoubleClick Campaign Manager API Forum
Hi Google team,

Sure.
I have sent the information to the email address that you indicated.

Could you please confirm the concise changes that I need to implement in the code obtain the report through the API?

Thank you!

Looking forward to your confirmation.

Regards,
Eshra

DCM API (DoubleClick Campaign Mgr)

unread,
Oct 1, 2020, 6:29:56 AM10/1/20
to mohamed.a...@gmail.com, google-doubleclick-...@googlegroups.com
Hi Mohamed,

Thank you for providing the requested information to the given email address. Could you please test our GitHub samples as the some of the steps are handled smoothly. Once you download the samples, please add client_secrets.json file in the same folder. 

DCM Python implementation app: https://github.com/googleads/googleads-dfa-reporting-samples/tree/master/python/v3_3

Mohamed Eshra

unread,
Oct 1, 2020, 11:28:59 AM10/1/20
to Google's DoubleClick Campaign Manager API Forum
Hi team,

Which sample code shall I use to download the latest report file of a scheduled offline report?

Thank you!

Looking forward to receiving your confirmation.

Regards,
Eshra

DCM API (DoubleClick Campaign Mgr)

unread,
Oct 1, 2020, 2:44:31 PM10/1/20
to mohamed.a...@gmail.com, google-doubleclick-...@googlegroups.com
Hi Eshra,

This is Lakshmi. I work along with Teejay. Teejay is recommending to download the Github samples where some of the OAuth steps are handled smoothly. Once you are able to successfully authorize and can make API requests, you can use the following links which covers the information regarding downloading the file:
  1. https://developers.google.com/doubleclick-advertisers/guides/download_reports
  2. https://github.com/googleads/googleads-dfa-reporting-samples/blob/master/python/v3_4/download_file.py

The latest file can be identified using 'sortField' LAST_MODIFIED_TIME (by default): https://developers.google.com/doubleclick-advertisers/v3.4/reports/files/list#parameters

Thanks,

Google Logo
Lakshmi Prathipati
DCM API Team
 



 

ref:_00D1U1174p._5004Q25Xb5m:ref
Message has been deleted

Mohamed Eshra

unread,
Oct 4, 2020, 7:25:27 PM10/4/20
to Google's DoubleClick Campaign Manager API Forum
Hi DCM API Team,

Could you please confirm the specific code that I need to use to download the latest report file of a scheduled offline report?
Also, could you please confirm the specific parts of the code that I would need to substitute on my pc for the code to work?

Thank you!

Regards,
Eshra

DCM API (DoubleClick Campaign Mgr)

unread,
Oct 5, 2020, 1:09:04 AM10/5/20
to mohamed.a...@gmail.com, google-doubleclick-...@googlegroups.com
Hi Mohamed,

You may use this sample code for downloading reports. In addition, we recommend to check our whole sample project as some of the OAuth steps are handled smoothly there. You may also want to check our report downloading guide for further information regarding to your concern.

Regards,
Google Logo
Teejay Wennie Pimentel
DCM API Team
 


ref:_00D1U1174p._5004Q25Xb5m:ref
Reply all
Reply to author
Forward
0 new messages