Last active
January 8, 2016 16:31
-
-
Save richieforeman/7a1b85ca896d2e38b556 to your computer and use it in GitHub Desktop.
Google API Tracing Token - Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service = build(serviceName="admin", | |
version="directory_v1", | |
http=httplib2.Http()) | |
# A tracing token can be attached by utilizing the 'trace' kwarg on a method call. | |
# Switching the request to utilize all 'kwargs' is recommended. | |
# | |
# Importantly, when a request (such as the one below) includes a body parameter, | |
# the tracing token should NOT be included in the body. | |
# | |
# The tracing token parameter will need to be added to EACH AND EVERY call where a tracing token is required. | |
# | |
# Additionally, the Python library "execute" method allows for a "num_retries" param, | |
# which is a baked in exponential backoff mechanism. | |
service.users().makeAdmin(trace="token:<<tracing token goes here>>", | |
userKey=username, | |
body={ | |
'status': True | |
}).execute(num_retries=5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment