Skip to content

Conversation

@lilyydu
Copy link
Contributor

@lilyydu lilyydu commented Nov 6, 2025

resolves: #367

  • exposed a new config option called ClientSettings thats passed into our clients from the app layer
  • the tokenUrl specifies the regional token endpoint to use (e.g., europe.token.botframework)

I didn't reuse OauthSettings because
a) its associated w/ the Apps ecosystem vs ClientSettings is concerned w the API layer
b) eventually may diverge with additional params
b) would cause circular dependencies

  • tested with the graph sample, works w/ global and a west-europe regional bot
  • add tests

INSTRUCTIONS FOR SETTING UP
(documenting here for now, should add to docs, partial courtesy to @Benjiiim):

const app = new App({
oauth: {
defaultConnectionName: 'graph',
// This is an example of overriding the token URL for a specific region (e.g., Europe).
// Uncomment this block if needed.
// clientSettings: {
// tokenUrl: "https://europe.token.botframework.com",
// }
},
logger: new ConsoleLogger('@tests/auth', { level: 'debug' })
});

resources:

@Benjiiim
Copy link

Benjiiim commented Nov 6, 2025

Loving it 😍 Thanks a lot @lilyydu for your work on this.

I have several comments after going through the changes.

Have you considered using OAuthUrl as the setting's name instead of tokenUrl? I understand the choice for tokenUrl as it is the URL to get the token but the bot service doc talks about OAuth URL in OAuth URL support in Azure AI Bot Service for example so it might be good to be aligned.

Regarding the instructions for setting up:

  • I don't think you should touch the azure.bicep file as resourceGroup().location will get the resource group location automatically + the resource group location doesn't change anything regarding the bot service resource location.
  • You should document the change needed in manifest.json as well. *.botframework.com should be replaced by europe.token.botframework.com (or equivalent for other locations)
  • I will be glad to have a look at the doc when time will come

Regarding the CLI templates:

  • If you choose to add a comment to define the tokenURL in index.ts, you might want to do the same with the validdomain in manifest.json.
  • And you might want to do that for the template applied when running config add atk.oauth to change the reply url in the aad.manifest.json file and the location in azurebot.bicep.
  • Instead of comments everywhere, I'm wondering if env variables won't be better? A discussion with M365 toolkit might be useful in that case to align the templates.
  • An other option would be to rely only on the documentation without touching the templates

Comment on lines +1 to +9
export type ClientSettings = {
/**
* the URL to use for managing user oauth tokens.
* Specify this value if you are using a regional bot.
* For e.g., https://europe.token.botframework.com
* Default is https://token.botframework.com
*/
readonly OAuthUrl?: string;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

camelCase?

readonly OAuthUrl?: string;
};

export const DEFAULT_CLIENT_SETTINGS: Required<ClientSettings> = {
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: Instead of making all keys optional in ClientSettings, and making DEFAULT_CLIENT_SETTINGS Required, you could make all keys required in ClientSettings, and make all parameters Partial. This way, in places you need ClientSettings, the value of the keys isn't string | undefined.
For eg, in sign-in.ts, you have:

`${this._clientSettings.OAuthUrl}/${BOT_SIGNIN_ENDPOINTS.URL}?${q}`

here OauthUrl is actually string | undefined, which is less understandable than if it was just string.

* For e.g., https://europe.token.botframework.com
* Default is https://token.botframework.com
*/
readonly OAuthUrl?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Also oauthUrl, or oauthBaseEndpoint? It's not really the full url. Thoughts?


this.bots = new BotClient(this.http);
this.users = new UserClient(this.http);
this._clientSettings = {...DEFAULT_CLIENT_SETTINGS, ...(clientSettings ?? {})};
Copy link
Contributor

Choose a reason for hiding this comment

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

this is copied in many places. Consider a helper method that takes in Partial<ClientSettings> and returns ClientSettings

* authentication. This is important to
* configure for regional bots.
*/
readonly clientSettings?: ClientSettings
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this in "OauthSettings". this seems more general than just Oauth, right?

* For e.g., https://europe.token.botframework.com
* Default is https://token.botframework.com
*/
readonly OAuthUrl?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, each of these should have an associated environment variable that populates them through a config, if not provided

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.

SSO - Support of regional Azure bots

6 participants