Skip to content

TokenSource config at runtime via options#256

Merged
MaxHeimbrock merged 6 commits intomainfrom
max/token-source-config-at-runtime
Apr 30, 2026
Merged

TokenSource config at runtime via options#256
MaxHeimbrock merged 6 commits intomainfrom
max/token-source-config-at-runtime

Conversation

@MaxHeimbrock
Copy link
Copy Markdown
Contributor

Background

In the first implementation of TokenSource, there was only the option to use a preconfigured config created as a ScriptableObject in the editor. Often you want to create the options at runtime (e.g. set participant name at runtime)

Changes

@MaxHeimbrock MaxHeimbrock marked this pull request as ready for review April 21, 2026 13:16
Comment thread Runtime/Scripts/TokenSource/TokenSource.cs Outdated
Comment thread Runtime/Scripts/TokenSource/TokenSource.cs Outdated
Comment thread Runtime/Scripts/TokenSource/TokenSourceFetchOptions.cs Outdated
Comment thread Runtime/Scripts/TokenSource/TokenSource.cs Outdated
Comment thread Runtime/Scripts/TokenSource/TokenSource.cs Outdated
Copy link
Copy Markdown
Contributor

@xianshijing-lk xianshijing-lk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm after you address the comments.

@MaxHeimbrock MaxHeimbrock force-pushed the max/token-source-config-at-runtime branch from 60b1f85 to e432074 Compare April 28, 2026 14:19
Comment thread Runtime/Scripts/TokenSource/TokenSourceHelper.cs Outdated
Comment thread Samples~/Meet/Assets/Runtime/MeetManager.cs Outdated
Copy link
Copy Markdown

@1egoman 1egoman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work with this!

Comment thread Runtime/Scripts/TokenSource/TokenSource.cs
Comment thread Runtime/Scripts/TokenSource/TokenSourceHelper.cs Outdated
case ITokenSourceFixed fixedSource:
if (options != null)
Debug.Log("Token source helper has fixed config, fetch options are ignored.");
return await fixedSource.FetchConnectionDetails();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: I think this is a little weird - the TokenSourceHelper sort of sometimes is an ITokenSourceFixed and sometimes an ITokenSourceConfigurable. I don't know if I see an obviously better way to fix this though so - the thing that immediately came to mind was like a TokenSourceHelperFixed / TokenSourceHelperConfigurable type of split but the user shouldn't really have to care about the difference. TokenSourceHelper<Fixed> / TokenSourceHelper<Configurable> has the same problem. So maybe this is just an inevitable downside to this single TokenSourceHelper approach.

question: Just for my own understanding, do you have access to the currently configured subtype of TokenSourceConfig while the user is editing the c# code in unity? Or do all you know is that "the config is a subtype of TokenSourceConfig and that's it". If it's the former, maybe there's something fancy that could be done here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is the ugliest part of the design right now. I think from a user perspective it is great to have one UI place where you can drag and drop / file select the config you want to use. I do that myself a lot.

My solution was the Debug.Log("Token source helper has fixed config, fetch options are ignored."); but I also forgot to promote it to a Debug.LogWarning. This would make you aware of the footgun.

I feel like the alternatives to split up the TokenSourceHelper into two is creating more UI chaos and the fixed TokenSource config is probably rarely used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not come up with a better solution right now. I think I will leave it as it is.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, makes sense. I couldn't come up with something better either so I think this is probably good enough as is.

Comment thread Runtime/Scripts/TokenSource/TokenSourceHelper.cs Outdated
Comment thread Runtime/Scripts/TokenSource/TokenSourceHelper.cs Outdated
Comment thread README.md Outdated
@MaxHeimbrock MaxHeimbrock merged commit 30f2b61 into main Apr 30, 2026
14 checks passed
@MaxHeimbrock MaxHeimbrock deleted the max/token-source-config-at-runtime branch April 30, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants