Skip to content
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

使用环境变量保存token,后续接口引用,不再需要手动复制更换token #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions rest-api-tts/postman/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ poatman 下载地址:https://www.getpostman.com/downloads/ 点击download 下

1.使用postman打开Tts.postman_collection.json文件

2.点击token请求页面,获取鉴权用的token
2.点击token请求页面,获取鉴权用的token。如果请求返回结果成功,postman执行tests中代码,将token自动保存到环境变量中。

3.点击tts请求页面,填入上一步获得的token,调用语音合成接口生成音频文件
3.点击tts请求页面,从环境变量中自动读取上一步获得的token,调用语音合成接口生成音频文件

### 导入Json文件

Expand All @@ -40,7 +40,7 @@ poatman 下载地址:https://www.getpostman.com/downloads/ 点击download 下

### 访问合成接口

1.点击之前左侧导入的Tts,选择第二个POST tts,在Body下x-www-form-urlencoded替换刚才获取的token的值,最后点击Send 测试;合成完成后,可以点击播放按钮试听,也可以点击右下角的download 下载合成音频文件 如下图
1.点击之前左侧导入的Tts,选择第二个POST tts,在Body下x-www-form-urlencoded引用环境变量中保存的token值 {{baidu_access_token}},最后点击Send 测试;合成完成后,可以点击播放按钮试听,也可以点击右下角的download 下载合成音频文件 如下图

![图片](https://raw.githubusercontent.com/Baidu-AIP/speech-demo/master/rest-api-tts/postman/doc-images/201906261702.png)
![图片](https://raw.githubusercontent.com/Baidu-AIP/speech-demo/master/rest-api-tts/postman/doc-images/201906261703.png)
Expand Down
26 changes: 23 additions & 3 deletions rest-api-tts/postman/Tts.postman_collection.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
{
"info": {
"_postman_id": "035030c6-9e6e-46e3-a007-9df1af3f3fdb",
"_postman_id": "f5b9914f-f960-431f-a1e5-2cecd0ceaab6",
"name": "Tts",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "token",
"event": [
{
"listen": "test",
"script": {
"id": "cf8629a2-cff7-4f15-8d8f-2f05469b615a",
"exec": [
"// 请求正常返回",
"pm.test(\"状态200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"// 将access_token保存为环境变量",
"var jsonData = pm.response.json();",
"pm.globals.set(\"baidu_access_token\", jsonData.access_token);"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
Expand Down Expand Up @@ -80,7 +99,7 @@
},
{
"key": "tok",
"value": "24.a7d12f1614a2b94102375641f145ab95.2592000.1563520275.282335-15803531",
"value": "{{baidu_access_token}}",
"description": "开放平台获取到的开发者access_token(见上面的“鉴权认证机制”段落)",
"type": "text"
},
Expand Down Expand Up @@ -173,5 +192,6 @@
"type": "string"
}
]
}
},
"protocolProfileBehavior": {}
}