| 38 | |
| 39 | |
| 40 | def main(argv): |
| 41 | # Load the json format key that you downloaded from the Google API |
| 42 | # Console when you created your service account. For p12 keys, use the |
| 43 | # from_p12_keyfile method of ServiceAccountCredentials and specify the |
| 44 | # service account email address, p12 keyfile, and scopes. |
| 45 | credentials = ServiceAccountCredentials.from_json_keyfile_name( |
| 46 | "service-account-abcdef123456.json", |
| 47 | scopes="https://www.googleapis.com/auth/tasks", |
| 48 | ) |
| 49 | |
| 50 | # Create an httplib2.Http object to handle our HTTP requests and authorize |
| 51 | # it with the Credentials. |
| 52 | http = httplib2.Http() |
| 53 | http = credentials.authorize(http) |
| 54 | |
| 55 | service = build("tasks", "v1", http=http) |
| 56 | |
| 57 | # List all the tasklists for the account. |
| 58 | lists = service.tasklists().list().execute(http=http) |
| 59 | pprint.pprint(lists) |
| 60 | |
| 61 | |
| 62 | if __name__ == "__main__": |