-
Notifications
You must be signed in to change notification settings - Fork 22
[apps/api] feat: allow oauth for regional bots #386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5e37503
43b2f30
c93d06a
483e2d9
1f054b2
43805c8
27a914a
41ad19c
a2ec93c
80fe27d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| 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; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also oauthUrl, or oauthBaseEndpoint? It's not really the full url. Thoughts?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| }; | ||
|
Comment on lines
+1
to
+9
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. camelCase? |
||
|
|
||
| export const DEFAULT_CLIENT_SETTINGS: Required<ClientSettings> = { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 `${this._clientSettings.OAuthUrl}/${BOT_SIGNIN_ENDPOINTS.URL}?${q}`here OauthUrl is actually string | undefined, which is less understandable than if it was just string. |
||
| OAuthUrl: 'https://token.botframework.com', | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import * as http from '@microsoft/teams.common/http'; | ||
|
|
||
| import { BotClient } from './bot'; | ||
| import { ClientSettings, DEFAULT_CLIENT_SETTINGS } from './client-settings'; | ||
| import { ConversationClient } from './conversation'; | ||
| import { MeetingClient } from './meeting'; | ||
| import { TeamClient } from './team'; | ||
|
|
@@ -26,8 +27,9 @@ export class Client { | |
| this._http = v; | ||
| } | ||
| protected _http: http.Client; | ||
| protected _clientSettings: ClientSettings; | ||
|
|
||
| constructor(serviceUrl: string, options?: http.Client | http.ClientOptions) { | ||
| constructor(serviceUrl: string, options?: http.Client | http.ClientOptions, clientSettings?: ClientSettings) { | ||
| this.serviceUrl = serviceUrl; | ||
|
|
||
| if (!options) { | ||
|
|
@@ -44,8 +46,10 @@ export class Client { | |
| }); | ||
| } | ||
|
|
||
| this.bots = new BotClient(this.http); | ||
| this.users = new UserClient(this.http); | ||
| this._clientSettings = {...DEFAULT_CLIENT_SETTINGS, ...(clientSettings ?? {})}; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
|
||
| this.bots = new BotClient(this.http, this._clientSettings); | ||
| this.users = new UserClient(this.http, this._clientSettings); | ||
| this.conversations = new ConversationClient(serviceUrl, this.http); | ||
| this.teams = new TeamClient(serviceUrl, this.http); | ||
| this.meetings = new MeetingClient(serviceUrl, this.http); | ||
|
|
@@ -57,3 +61,4 @@ export * from './bot'; | |
| export * from './conversation'; | ||
| export * from './meeting'; | ||
| export * from './team'; | ||
| export * from './client-settings'; | ||
Uh oh!
There was an error while loading. Please reload this page.