I am getting the credentials and storing it to a .dat file

oauth2_client_id = '12121212121212121'
oauth2_client_secret = 'JHJHJHJHJHJGHGH'
email="[email protected]"
client_customer_id='hnjhjhjh'def main():
    storage=Storage('c:\Mypath\SampleAD.dat')
    credential =storage.get()
    if credential is None:
    scope=['https://adwords.google.com/api/adwords']
    flow = OAuth2WebServerFlow(
         
client_id=oauth2_client_id,client_secret=oauth2_client_secret,scope=scope,user_agent='SampleAPI',redirect_uri='urn:ietf:wg:oauth:2.0:oob')
    authorize_url = flow.step1_get_authorize_url()
    print authorize_url
    webbrowser.open(authorize_url,)
    print ('Log in to your Google Account and open the following URL: 
\n%s\n'%authorize_url)
    print 'After approving the token enter the verification code (if 
specified).'
    code = raw_input('Code: ').strip()
    try:
        credential = flow.step2_exchange(code)
        storage=Storage('Mypath\SampleAd.dat')
        client = AdWordsClient(headers={'developerToken': '%s' % email,
                                            'clientCustomerId': 
client_customer_id,
                                            'userAgent': 'SampleAPI',
                                            'oauth2credentials': credential
                                            })
        credentials = client.oauth2credentials
        print 'OAuth2 authorization successful!'
        credentials.refresh(httplib2.Http())
        client.oauth2credentials = credentials
        campaign_service = client.GetCampaignService(version='v201309')
        print campaign_service
            # OAuth2 credentials objects can be reused
        credentials = client.oauth2credentials
        client.oauth2credentials = credentials
        http = httplib2.Http()
        print http
        print 'OAuth2 authorization successful!'
        storage.put(credentials)
  except FlowExchangeError as e:
        sys.exit('Authentication has failed: %s' % e)

After the Successful authentication I am trying to download the report. I 
am getting this ERROR

adspygoogle.adwords.AdWordsErrors.AdWordsReportError: HTTP code: 400, 
type:'QuotaCheckError.INVALID_TOKEN_HEADER', trigger: '[email protected]', field 
path: ''

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to