import { TeamsFx, createApiClient, AuthProvider } from "@microsoft/teamsfx"; import { AxiosRequestConfig } from "axios"; // A custom authProvider implements the `AuthProvider` interface. // This sample authProvider implementation will set a custom property in the request header class CustomAuthProvider implements AuthProvider { customProperty: string; customValue: string; constructor(customProperty: string, customValue: string) { this.customProperty = customProperty; this.customValue = customValue; } // Replace the sample code with your own logic. AddAuthenticationInfo: (config: AxiosRequestConfig) => Promise = async ( config ) => { if (!config.headers) { config.headers = {}; } config.headers[this.customProperty] = this.customValue; return config; }; } // Load application configuration const teamsFx = new TeamsFx(); const authProvider = new CustomAuthProvider( // You can also add configuration to the file `.env.teamsfx.local` and use `process.env.{setting_name}` to read the configuration. For example: // process.env.TEAMSFX_API_{{capitalName}}_CUSTOM_PROPERTY, // process.env.TEAMSFX_API_{{capitalName}}_CUSTOM_VALUE "customPropery", "customValue" ); // Initialize a new axios instance to call {{config.APIName}} const {{config.APIName}}Client = createApiClient( process.env.TEAMSFX_API_{{capitalName}}_ENDPOINT, authProvider ); export { {{config.APIName}}Client };