Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tym-xqo opened this issue May 28, 2016 · 5 comments

Comments

@tym-xqo
Copy link

tym-xqo commented May 28, 2016

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
@nicholaschen
Copy link
Contributor

Hiya,

I think this is actually caused by another issue with regards to proxies that we're working on, but I'll take another look.

Cheers,
Nick

@nicholaschen
Copy link
Contributor

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

Thanks for your patience!

@RogerWebb
Copy link

I've installed the current version of googleads and the issue is still present.

From pip freeze:
googleads==8.0.0

I've installed, uninstalled, reinstalled, and I still get the error.

@grivescorbett
Copy link
Contributor

Hello!

Would you mind sharing your stack trace / code or is it exactly the same as the original issue?

@grivescorbett grivescorbett reopened this Oct 3, 2017
@msaniscalchi
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants