Skip to content

Instantly share code, notes, and snippets.

@richieforeman
Last active January 8, 2016 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richieforeman/7a1b85ca896d2e38b556 to your computer and use it in GitHub Desktop.
Save richieforeman/7a1b85ca896d2e38b556 to your computer and use it in GitHub Desktop.
Google API Tracing Token - Python
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