前提条件
操作步骤
Web 客户端调用 API
1. 登录 API 网关控制台,在左侧导航栏中,单击服务 > 基本信息,进入服务基本信息页面。
2. 在服务基本信息页面,选择之前所创建的服务,单击“服务名”,进入该服务的 API 管理界面。
![](https://qcloudimg.tencent-cloud.cn/image/document/a73e7f2a947a95ac2f09552fa31f4e7e.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/a73e7f2a947a95ac2f09552fa31f4e7e.png)
3. 在 API 管理界面,选择所需的ID,单击“ID/名称”,进入该 ID 的基本信息页面。
![](https://qcloudimg.tencent-cloud.cn/image/document/5a9d91ae86294d568a65e70507137bbe.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/5a9d91ae86294d568a65e70507137bbe.png)
4. 在基本信息页面,取 API 访问地址,如下:
![](https://qcloudimg.tencent-cloud.cn/image/document/56b9e80200a995cc5cd05011db5651e7.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/56b9e80200a995cc5cd05011db5651e7.png)
5. 通过浏览器发起访问 API,自动跳转到 EIAM 认证门户登录页面输入账号和密码,单击登录,成功登录后会返回 API 输出信息。
![](https://qcloudimg.tencent-cloud.cn/image/document/6cb301e6c83285164e7532ec44b2d8d8.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/c7cd2c424c846f4948bcb093343f0bae.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/6cb301e6c83285164e7532ec44b2d8d8.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/c7cd2c424c846f4948bcb093343f0bae.png)
非 Web 客户端调用 API
1. 登录 API 网关控制台,在左侧导航栏中,单击服务 > 基本信息,进入服务基本信息页面。
2. 在服务基本信息页面,选择之前所创建的服务,单击“服务名”,进入该服务的 API 管理界面。
![](https://qcloudimg.tencent-cloud.cn/image/document/fd1e611322374922dbfcb57e5b0d83b6.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/fd1e611322374922dbfcb57e5b0d83b6.png)
3. 在 API 管理界面,选择所需的ID,单击“ID/名称”,进入该 ID 的基本信息页面。
![](https://qcloudimg.tencent-cloud.cn/image/document/495c40cbab15ce58155acb6cc4bf0e9f.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/495c40cbab15ce58155acb6cc4bf0e9f.png)
4. 在基本信息页面,取 API 访问地址,如下:
![](https://qcloudimg.tencent-cloud.cn/image/document/c361af26e8d2f10a8183996d60bbd49d.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/c361af26e8d2f10a8183996d60bbd49d.png)
5. 通过后端程序、postman 等方式,携带 username、password 参数发起访问授权 API,获取返回的 JWT 格式的 id_token,如下:
![](https://qcloudimg.tencent-cloud.cn/image/document/b6915aac602b016e6d92b9bcc8035dcf.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/b6915aac602b016e6d92b9bcc8035dcf.png)
6. 通过后端程序、postman 等方式,在 HTTP 头部 Authorization 域携带 id_token 参数,以及其他业务参数,访问业务API,如下:
![](https://qcloudimg.tencent-cloud.cn/image/document/82a88388cd9741f61a943cddd14b0ff9.png)
![](https://qcloudimg.tencent-cloud.cn/image/document/82a88388cd9741f61a943cddd14b0ff9.png)