feat: add Experiment Center override params to AuthorizationParameters - #177
Conversation
|
LGTM. Could we also add a short section in README (referencing to the example provided) |
| # specific variation instead of the automatic assignment, for this request only. | ||
| # variation_id and segment_id both require experiment_id; segment_id applies only | ||
| # to segment-targeted experiments. | ||
| experiment_id: Optional[str] = None |
There was a problem hiding this comment.
One design thing worth noting. This model defines the params as typed fields, but the login path reads authorization_params as a plain dict, so the typed fields here don't actually flow into the call path or give type checking at the call site. I see you already called this out in the PR description as a known gap, so I'm not asking to change it in this PR.
Is dict the intended shape for now?
There was a problem hiding this comment.
Yes, dict is what we want for now.
The typed fields on AuthorizationParameters are only there for parity and to help discovery.
The login path still reads authorization_params as a plain dict. I didn't want to change this pattern in this PR as this is a pre-existing pattern in this SDK.
Addressed in f2eb2f6 |
Summary
This PR adds the Auth0
Experiment Centeroverride params (experiment_id,variation_id,segment_id) to interactive login, for parity with the other Auth0 SDKs.By default Auth0 assigns each user to an experiment variation automatically. Passing these params on a login call forces a specific
experiment,variation, orsegment, which helps when you want to reproduce a variation while debugging. The override applies to that one login request only.Changes
auth_types/__init__.py: addedexperiment_id,variation_id, andsegment_idas optionalstrfields on theAuthorizationParametersmodel.tests/test_server_client.py: addedtest_start_interactive_login_forwards_experiment_center_params, which checks that all three params reach the/authorizerequest.examples/InteractiveLogin.md: added anExperiment Center Overridessection that shows how to pass the params per login call.How it works
start_interactive_loginalready forwards any extraauthorization_paramsto the/authorizeURL, because these keys are not in theINTERNAL_AUTHORIZE_PARAMSdenylist. The new fields just explicit and typed. This is an additive, non-breaking change.Testing
poetry run pytest:611 passed.poetry run ruff check .:Note
These are both pre-existing and deliberately left out of this surgical commit:
InteractiveLogin.mdexamples callstart_interactive_login({...})with a rawdict, which does not match the code, since it readsoptions.authorization_paramsas an attribute. The new section uses the correctStartInteractiveLoginOptions(...)form.AuthorizationParametersis vestigial. It is defined but never instantiated or used as a type, so these new fields are for parity only. It should be wired in or removed in a later change.