更新时间:2022-07-29 GMT+08:00
分享

认证鉴权

Token认证:通过Token认证调用请求。

Token的有效期为20分钟,需要使用一个Token鉴权时,可以先缓存起来,避免频繁调用。

Token在计算机系统中代表令牌(临时)的意思,拥有Token就代表拥有某种权限。Token认证就是在调用API的时候将Token加到请求消息头,从而通过身份认证,获得操作API的权限。

Token可通过调用获取用户Token接口获取,

请求示例:

POST https://isdpcloud.huawei.com/oauth2/oauth/rest_token
HEADERS:
Content-Type : application/json
请求返回-Body:
{
    "access_token": "********-****-****-****-************weE+************************ztxUMZ0lKp8yECU=",
    "token_type": "****er",
    "refresh_token": "********-****-****-****-************************uHnL+************wzpFG6vHcHZ2n0=",
    "expires_in": 359,
    "scope": "all",
    "plat_user": {
        "userId": 97232,
        "userNo": "sdcph4f1A4HvfVEVk7SZWhTzlu10pdSh",
        "userName": "TestRTC",
        "userType": "API",
        "phone": null,
        "tenantId": 50222,
        "status": "0",
        "deleteFlag": 0,
        "pwdUpdateDate": "2021-12-02T02:51:59.000+00:00",
        "userExtendMap": {
            "clientId": "isdp-saas-openapi",
            "userPrivacyAgreement": {
                "privacyAgreementAction": "0",
                "privacyPolicyAction": "0",
                "privacyAgreementVX": null,
                "privacyAgreementVXAction": "1",
                "serviceAgreement": "V5",
                "privacyPolicy": "V2",
                "privacyAgreement": "V4",
                "serviceAgreementAction": "0"
            },
            "versionMap": {
                "privacyAgreement": "V4"
            }
        },
        "password": null,
        "salt": null,
        "currentLoginType": "password"
    }
}

以上示例token口令为:

************0c-****-****-****-****c8061d18weE+znJSEciloPJWkWlCvZNbpFLaztxUMZ0lKp8yECU=

, beaer后加一个英文输入法下的空格

获取Token后,再调用其他接口时,您需要在请求消息头中添加“Authorization”,其值即为Token。例如Token值为“bearer 716....”,则调用接口时将“Authorization: bearer 716....”加到请求消息头即可,如下所示。

POST https://isdpcloud.huawei.com/openapi/v1/rtcLive/captureVideo
Content-Type: application/json
Authorization: bearer 716....

相关文档