Guest User

Untitled

a guest
Jul 21st, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. Traceback (most recent call last):
  2. File "email_clean.py", line 14, in <module>
  3. creds = store.get()
  4. File "C:Python27libsite-packagesoauth2clientclient.py", line 407, in get
  5. return self.locked_get()
  6. File "C:Python27libsite-packagesoauth2clientfile.py", line 54, in locked_get
  7. credentials = client.Credentials.new_from_json(content)
  8. File "C:Python27libsite-packagesoauth2clientclient.py", line 302, in new_from_json
  9. module_name = data['_module']
  10. KeyError: '_module'
  11.  
  12. """
  13. Shows basic usage of the Gmail API.
  14.  
  15. Lists the user's Gmail labels.
  16. """
  17. from __future__ import print_function
  18. from apiclient.discovery import build
  19. from httplib2 import Http
  20. from oauth2client import file, client, tools
  21.  
  22. # Setup the Gmail API
  23. SCOPES = 'https://www.googleapis.com/auth/gmail.readonly'
  24. store = file.Storage('token.json')
  25. creds = store.get()
  26. if not creds or creds.invalid:
  27. flow = client.flow_from_clientsecrets('credentials.json', SCOPES)
  28. creds = tools.run_flow(flow, store)
  29. service = build('gmail', 'v1', http=creds.authorize(Http()))
  30.  
  31. # Call the Gmail API
  32. results = service.users().labels().list(userId='me').execute()
  33. labels = results.get('labels', [])
  34. if not labels:
  35. print('No labels found.')
  36. else:
  37. print('Labels:')
  38. for label in labels:
  39. print(label['name'])
Add Comment
Please, Sign In to add comment