Snippets

Lucas Correia Debug API usage

Created by Lucas Correia last modified

Instructions

  1. Edit /opt/ftrack/nginx/conf/nginx_https.conf or /opt/ftrack/nginx/conf/nginx_http.conf
  2. Find log_format configuration, and comment out the lines. Add the configuration from this snippet.
  3. Reload the Configuration; /opt/ftrack/nginx/sbin/nginx -s reload
  4. Use the method in set_session_client_token.py to set the client token for the Python API. For any integration using the JS API, you can pass in clientToken option when creating the session.
1
2
3
4
5
    # Custom log format
	log_format scrubbed '$remote_addr - $remote_user [$time_local] '
                        '"$scrubbed_request" $status $body_bytes_sent '
                        '"$http_referer" "$http_user_agent" '
                        'debug_api:"$http_ftrack_user" "$http_ftrack_clienttoken" $request_time';
def patch_request_add_client_token(original, client_token):
    def add_request_headers(self, *args, **kwargs):
        kwargs['headers'].update({ 'ftrack-clientToken': client_token })
        return original(self, *args, **kwargs)
    return add_request_headers

def set_session_client_token(session, client_id):
    import uuid
    custom_client_token = '{}--{}'.format(client_id, uuid.uuid4())
    session._request.post = patch_request_add_client_token(
        session._request.post,
        custom_client_token
    )

# Configure *session* to send a ClientToken begining with "company-tool-foo"
set_session_client_token(session, 'company-tool-foo')

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.