title: Basic Google API Oauth2 Authentication Setup Fails To Give Objects?
body: <p>I have coded an authentication and I get an access token, but when I use it to grab an object I just end up getting <code>'NoneType' object is not callable</code>.</p>
  
  <pre><code> Exception Location: googleads\adwords.py in GetService, line 365
   Exception Type: Type Error
   Exception Value: Internal Server Error: /oauth2callback
  </code></pre>
  
  <p>I get the same result whether calling for Customer or CampaignService. I don't understand what I am doing wrong.</p>
  
  <p>I am following the code in <a href="https://github.com/googleads/googleads-python-lib/blob/master/examples/adwords/authentication/create_adwords_client_with_access_token.py" rel="nofollow noreferrer">Googleads</a>.</p>
  
  <pre><code>def getAdwordsFlow():
      FLOW.redirect_uri = 'http://localhost/oauth2callback'
  
      # Generate URL for request to Google's OAuth 2.0 server.
      authorization_url, state = FLOW.authorization_url(
          access_type='offline',
          include_granted_scopes='true')
      return authorization_url
  
  
  def getAdwordsTokens(request):
      auth_code = request.GET.get('code')
      FLOW.fetch_token(code=auth_code)
      credentials = FLOW.credentials
  
      oauth2_client = oauth2.GoogleAccessTokenClient(
      FLOW.credentials.token, FLOW.credentials.expiry)
  
      adwords_client = adwords.AdWordsClient(
      "DEVELOPER-TOKEN", oauth2_client, "USER-AGENT", "CLIENT-CUSTOMER-ID")
  
      customer = adwords_client.GetService('CustomerService').getCustomers()[0]
      print('You are logged in as customer: %s' % customer['customerId'])
  
      return HttpResponseRedirect("/")
  </code></pre>
  
  <p>url.py</p>
  
  <pre><code>urlpatterns = [
      re_path(r'^oauth2callback', queries.getAdwordsTokens, name='auth_calledback'),] #How 
  </code></pre>
  
  <p>view.py</p>
  
  <pre><code>def index(request):
      return redirect(getAdwordsFlow())
  </code></pre>
  
  <p>Terminal output:</p>
  
  <p><code>"GET /oauth2callback?state=XXXXXXXXX&amp;code=4/XXXXXXXXXXX&amp;scope=https://www.googleapis.com/auth/adwords+https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/userinfo.email HTTP/1.1" 500 80213</code>
  Why is it 500?</p>
  
  <p>I notice my access token has a different value when I call for it. So I am assuming it's working.</p>