question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v4.0.0 and higher: AttributeError: 'NoneType' object has no attribute 'proxy_info' when attempting to connect to DFP using a service account.

See original GitHub issue

Expected behavior

A service account with suitable privileges assigned should be able to connect to DFP services

Actual behavior

Attempts to connect to DFP with a valid service account result in Python AttributeError, apparently because GoogleServiceAccountClient.Refresh.proxy_config returns None.

Information

Some of my code started failing following googleads upgrade. To isolate the behavior to googleads, I composed the following simple test case, to connect to the DFP network service (based mainly on copy and paste from https://github.com/googleads/googleads-python-lib/tree/master/examples/dfp)

from googleads import dfp
from googleads import oauth2

# OAuth2 credential information. In a real application, you'd probably be
# pulling these values from a credential storage.
SERVICE_ACCOUNT_EMAIL = 'fake-pretend@developer.gserviceaccount.com'
KEY_FILE = '/secret/gcskey.p12'

# DFP API information.
APPLICATION_NAME = 'fake-pretend'


def dfp_api_client():

    oauth2_client = oauth2.GoogleServiceAccountClient(
            oauth2.GetAPIScope('dfp'), SERVICE_ACCOUNT_EMAIL, KEY_FILE)
    dfp_client = dfp.DfpClient(oauth2_client, APPLICATION_NAME)
    return dfp_client


def main(client):
    # directly from https://github.com/googleads/googleads-python-lib/blob/master/examples/dfp/v201602/network_service/get_all_networks.py
    # Initialize appropriate service.
    network_service = client.GetService('NetworkService', version='v201602')

    # Get all networks that you have access to with the current login credentials.
    networks = network_service.getAllNetworks()

    # Display results.
    for network in networks:
        print ('Network with network code \'%s\' and display name \'%s\' was found.'
             % (network['networkCode'], network['displayName']))

    print '\nNumber of results found: %s' % len(networks)

if __name__ == '__main__':
  # Initialize client object.
  dfp_client = dfp_api_client()
  main(dfp_client)

This works entirely as expected at v3.15.0, but fails with the following traceback with v4.0.0 and higher:

Traceback (most recent call last):
  File "api-test.py", line 37, in <module>
    dfp_client = dfp_api_client()# dfp.DfpClient.LoadFromStorage()
  File "api-test.py", line 16, in dfp_api_client
    oauth2.GetAPIScope('dfp'), SERVICE_ACCOUNT_EMAIL, KEY_FILE)
  File "/Users/thomas/.virtualenvs/tmp-1e8b453a8dbebace/lib/python2.7/site-packages/googleads/oauth2.py", line 203, in __init__
    self.Refresh()
  File "/Users/thomas/.virtualenvs/tmp-1e8b453a8dbebace/lib/python2.7/site-packages/googleads/oauth2.py", line 236, in Refresh
    proxy_info=self.proxy_config.proxy_info,
AttributeError: 'NoneType' object has no attribute 'proxy_info'

Steps to reproduce

  1. Install googleads 3.15.0
  2. Attempt connection to DFP API using a service account, which should work
  3. upgrade to googleads 4.x
  4. Attempt connection again

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nicholaschencommented, Jun 17, 2016

My colleague Mark has found the issue, and is going to release this with the next lib push.

Thanks for your patience!

0reactions
msaniscalchicommented, Dec 22, 2017

Closing as this has been open for some time without any response, feel free to reopen if it remains reproducible and you can provide additional information.

Regards, Mark

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why do I get AttributeError: 'NoneType' object has no attribute ...
NoneType means that instead of an instance of whatever Class or Object you think you're working with, you've actually got None .
Read more >
*** AttributeError: 'NoneType' object has no attribute 'Call'
We recently migrated to Google API V9, and we encounter this problem when trying to. create a new account budget proposal: We use...
Read more >
GDC-3086: Google Big Query Error AttributeError: 'NoneType ...
Error: AttributeError: 'NoneType' object has no attribute ... when connecting to Google Big Query with Service-to-Service authentication:
Read more >
Gmail: 'NoneType' object has no attribute 'name' error
Hey! I keep getting this error on my Zap. The Zap I am trying to set up is an TRIGGER for a new...
Read more >
T145505 'NoneType' object has no attribute 'lstrip'
... thumbor@8821[52527]: AttributeError: 'NoneType' object has no attribute ... 500 GET /wikipedia/en/thumb/4/45/Denver_Broncos_alternate_logo.svg/731px- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found