@microsoft/teamsfx 0.7.0 → 0.7.1-alpha.44ac039f1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -7
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -205,14 +205,13 @@ Use `axios` library to make HTTP request to Azure Function.
|
|
|
205
205
|
|
|
206
206
|
```ts
|
|
207
207
|
const teamsfx = new TeamsFx();
|
|
208
|
-
const
|
|
208
|
+
const credential = teamsfx.getCredential();
|
|
209
|
+
// Create an API client that uses SSO token to authenticate requests
|
|
210
|
+
const apiClient = createApiClient(
|
|
211
|
+
teamsfx.getConfig("apiEndpoint"),
|
|
212
|
+
new BearerTokenAuthProvider(async ()=> (await credential.getToken(""))!.token));
|
|
209
213
|
// Call API hosted in Azure Functions on behalf of user
|
|
210
|
-
const
|
|
211
|
-
const response = await axios.default.get(apiEndpoint + "api/httptrigger1", {
|
|
212
|
-
headers: {
|
|
213
|
-
authorization: "Bearer " + token,
|
|
214
|
-
},
|
|
215
|
-
});
|
|
214
|
+
const response = await apiClient.get("/api/" + functionName);
|
|
216
215
|
```
|
|
217
216
|
|
|
218
217
|
### Access SQL database in Azure Function
|
|
@@ -287,6 +286,27 @@ dialogs.add(
|
|
|
287
286
|
);
|
|
288
287
|
```
|
|
289
288
|
|
|
289
|
+
### Create API client to call existing API in Bot / Azure Function
|
|
290
|
+
|
|
291
|
+
```ts
|
|
292
|
+
const teamsfx = new TeamsFx();
|
|
293
|
+
|
|
294
|
+
// Create an API Key auth provider. Following auth providers are also available:
|
|
295
|
+
// BearerTokenAuthProvider, BasicAuthProvider, CertificateAuthProvider
|
|
296
|
+
const authProvider = new ApiKeyProvider("your_api_key_name",
|
|
297
|
+
teamsfx.getConfig("YOUR_API_KEY_VALUE"), // This reads the value of YOUR_API_KEY_VALUE environment variable
|
|
298
|
+
ApiKeyLocation.Header);
|
|
299
|
+
|
|
300
|
+
// Create an API client using above auth provider
|
|
301
|
+
// You can also implement AuthProvider interface and use it here
|
|
302
|
+
const apiClient = createApiClient(
|
|
303
|
+
teamsfx.getConfig("YOUR_API_ENDPOINT"), // This reads YOUR_API_ENDPOINT environment variable
|
|
304
|
+
authProvider);
|
|
305
|
+
|
|
306
|
+
// Send a GET request to "relative_api_path"
|
|
307
|
+
const response = await apiClient.get("relative_api_path");
|
|
308
|
+
```
|
|
309
|
+
|
|
290
310
|
## Advanced Customization
|
|
291
311
|
|
|
292
312
|
### Configure log
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/teamsfx",
|
|
3
|
-
"version": "0.7.0",
|
|
3
|
+
"version": "0.7.1-alpha.44ac039f1.0",
|
|
4
4
|
"description": "Microsoft Teams Framework for Node.js and browser.",
|
|
5
5
|
"main": "dist/index.node.cjs.js",
|
|
6
6
|
"browser": "dist/index.esm2017.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@azure/identity": "^2.0.1",
|
|
50
50
|
"@azure/msal-browser": "^2.21.0",
|
|
51
51
|
"@azure/msal-node": "~1.1.0",
|
|
52
|
-
"@microsoft/adaptivecards-tools": "
|
|
52
|
+
"@microsoft/adaptivecards-tools": "0.1.7-alpha.44ac039f1.0",
|
|
53
53
|
"@microsoft/microsoft-graph-client": "^3.0.1",
|
|
54
54
|
"axios": "^0.24.0",
|
|
55
55
|
"botbuilder": ">=4.15.0 <5.0.0",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"webpack": "^5.62.1",
|
|
129
129
|
"yargs": "^17.2.1"
|
|
130
130
|
},
|
|
131
|
-
"gitHead": "
|
|
131
|
+
"gitHead": "efc9714a46c6fa4cf0af322776b8b0ee26961d16",
|
|
132
132
|
"publishConfig": {
|
|
133
133
|
"access": "public"
|
|
134
134
|
},
|