API网关在Token组件下接入的原理:
先访问网关提供的认证接口,获取Token,再在请求头里带上Token访问API。我们先用Chrome Restlet Client插件进行测试。

1、认证接口请求地址:http://112.124.45.134:9000/xbg/api/appLogin

请求参数

{
"appID": "dd3b4faa-fe87-47ec-b089-8862db102fe9",
"secretKey": "c3a4b8c403c84bdc80419ca08261bd29"
}

认证成功返回结果

{
"result": true,
"token": "23423fwafasrser213423fsafwegasd",
"respErrMsg": {}
}

2、访问http://112.124.45.134:9000/quickstart/subject/categoryList , http头中加上认证成功时返回的token。
api_gateway_auth_token:23423fwafasrser213423fsafwegasd

最终将返回以下的内容:

{
    "code": "00",
    "message": "操作成功",
    "data": {
        "newYearCategoryList": [
            "小学1-3年级",
            "小学4-6年级",
            "初中"
        ],
        "generalCategoryList": [
            "语文",
            "数学",
            "英语",
            "历史",
            "军事",
            "化学",
            "搞笑",
            "其他",
            "生物",
            "体育"
        ]
    }
}

results matching ""

    No results matching ""