认证授权

获取访问凭证

1.接口说明

接口路径:/ac/openapi/v2/tokens

请求方式:POST

请求数据类型:application/json

接口描述:区域资源用户认证,认证成功后返回各区域ID、名称以及区域接口访问凭证token

备注:

1、每次访问为用户可用的计算区域分别颁发一个token,此token为访问其他服务接口的凭证,在后续接口请求中均需要携带。每个区域的token配合获取授权区域接口返回的URL地址,携带token调用作业、文件、容器等接口。

2、若用户有某个区域的访问权限,但账户状态为停用状态时,则返回区域信息,但token为null,无法调用后续接口,需充值后才能正常调用接口。

3、clusterId为0,clusterName为ac的区域信息为平台自身token,仅支持调用平台层面接口,如认证授权和用户资源及资源。

2.请求消息

参数说明: Headers:

名称 类型 必填 描述 示例
userstring用户名test
passwordstring用户密码111111
orgIdstring线下颁发给第三方的唯一标记码b86b8b86c98ce...

3.请求示例

cURL请求示例

curl --location --request POST 'https://api01.xxx.com:65102/ac/openapi/v2/tokens' \
--header 'Content-Type: application/json' \
--header 'user: test' \
--header 'password: test@123' \
--header 'orgid: 6048ce7ba15c2af2e8cec12991ec13cf'

Java请求示例

import okhttp3.*;

public class GetUserTokenDemo {

    public static final String URL = "https://api01.xxx.com:65102/ac/openapi/v2/tokens";
    public static final String USER = "test";
    public static final String PASSWD = "test@123";
    public static final String ORGID = "6048ce7ba15c2af2e8cec12991ec13cf";

    public static void main(String[] args) throws Exception {
        OkHttpClient client = new OkHttpClient().newBuilder()
                .build();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "");
        Request request = new Request.Builder()
                .url(URL)
                .method("POST", body)
                .addHeader("Content-Type", "application/json")
                .addHeader("user", USER)
                .addHeader("password", PASSWD)
                .addHeader("orgid", ORGID)
                .build();
        Response response = client.newCall(request).execute();
        System.out.println(response.body().string());
    }
}

Python请求示例

import requests
import json

url = "https://api01.xxx.com:65102/ac/openapi/v2/tokens"

payload = {}
headers = {
  'Content-Type': 'application/json',
  'user': 'test',
  'password': 'test@123',
  'orgid': '6048ce7ba15c2af2e8cec12991ec13cf'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

4.响应消息

返回参数:

名称 类型 描述 示例
msgstring信息0
codestring状态码success
dataarray区域信息列表
clusterNamestring区域名称OpenAPI计算中心
clusterIdstring区域ID11112
tokenstring区域tokeneyJhbGciOiJIUzI1NiIsInR5cC...

返回示例:

{
    "msg": "success",
    "code": "0",
    "data": [
        {
            "clusterName": "OpenAPI计算中心",
            "clusterId": "11112",
            "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6Imhhb3dqIiwiYWNjb3VudFN0YXR1cyI6Ik93ZSIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2MzQyODY2MDMwNjYiLCJjbHVzdGVySWQiOiIxMTEyNiIsImludm9rZXIiOiJ4eHl5YWdlYSIsInVzZXIiOiJoYW93aiJ9.mprLWvhNLNK1YuQVLewnJ7AG10K644g38xAt-xO3GwY"
        },
        {
            "clusterName": "test中心",
            "clusterId": "111131",
            "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6Imhhb3dqIiwiYWNjb3VudFN0YXR1cyI6IkRpc2FibGUiLCJjcmVhdG9yIjoiYWMiLCJyb2xlIjoiMSIsImV4cGlyZVRpbWUiOiIxNjM0Mjg2NjAzMDgwIiwiY2x1c3RlcklkIjoiMTExMTMxIiwiaW52b2tlciI6Inh4eXlhZ2VhIiwidXNlciI6Imhhb3dqIn0.zKhISUwMa2Y16SH0LOBvfSJN_ctvABPUHMsjHj7vJfA"
        },
        {
            "clusterName": "ac",
            "clusterId": "0",
            "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6Imhhb3dqIiwiYWNjb3VudFN0YXR1cyI6Ik93ZSIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2MzQyODY2MDMwODciLCJjbHVzdGVySWQiOiIxMTEyNSIsImludm9rZXIiOiJ4eHl5YWdlYSIsInVzZXIiOiJoYW93aiJ9.bIGdJpUoCZaKSJB71o_ZKUBzpcdW4_y54afU_arRDIQ"
        }
    ]
}

5.错误码

错误码 说明
10001 内部错误
10003 参数不全
10004 参数无效
10008 权限不足
10009 没有权限访问接口
0 接口调用成功

results matching ""

    No results matching ""