Setting Credentials

Sample Lifecycle Hooks Script

from stoobly_agent.app.proxy.context import InterceptContext
from stoobly_agent.config.constants import record_policy, replay_policy

def handle_before_request(context: InterceptContext):
    intercept_settings = context.intercept_settings
    flow = context.flow
    headers = flow.request
    request = request.headers
    
    is_replaying = intercept_settings.policy == replay_policy.ALL
    is_overwriting = intercept_settings.policy == record_policy.OVERWRITE
    if is_replaying or is_overwriting:
        # Handle setting credentials here
        # e.g. headers['authorization'] = '<TOKEN>'
        pass
    

Last updated