创建成员邀请链接

更新时间:
复制 MD 格式

创建TokenPlan成员邀请链接

前提条件

已获取阿里云账号或 RAM 用户的 AccessKey,并已为其授予调用本接口所需的 RAM 权限。建议将 AccessKey 配置为环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID 和 ALIBABA_CLOUD_ACCESS_KEY_SECRET,避免明文写入代码。

接口

POST/tokenplan/invite/link/create

本接口是阿里云 OpenAPI,采用 AccessKey 签名(签名算法 ACS3-HMAC-SHA256),不支持 Authorization: Bearer {API_KEY} 方式。请求需携带公共请求头 x-acs-action: CreateTokenPlanInviteLink、x-acs-version: 2026-02-10、x-acs-date、x-acs-content-sha256、x-acs-signature-nonce 以及 Authorization。

推荐使用阿里云 SDK 或 OpenAPI Explorer 发起调用,可免去自行计算签名。详细说明见认证。

用户只允许拥有一个有效的邀请链接
若用户已有有效的邀请链接,该接口将返回这个链接
若需要创建新的链接,请调用 RevokeTokenPlanInviteLink 接口失效当前的链接
该接口只返回生成的 token,邀请链接的拼接格式为 https://{host}/accept-invite?token=[token]&orgId=[orgId]
host 为 tokenplan-enterprise.bailian.aliyunportal.com

请求参数

所有参数均通过 Query String 传递。

ExpireTypestring可选

过期档位,默认 DAYS_7
DAYS_7
DAYS_30
MONTHS_6
YEAR_1

SsoSourcestring必填

邀请链接绑定的 SSO 登录方式:
SAML
DINGTALK

返回参数

Successboolean

调用接口是否成功:
true:成功
false:失败

Codestring

响应状态码。

Messagestring

响应信息。

Dataobject

业务参数

Tokenstring

生成的 Token

请求示例

本接口使用阿里云 OpenAPI 签名,下例中 ${SIGNATURE} 需按 ACS3-HMAC-SHA256 算法计算得出,x-acs-date、x-acs-signature-nonce 需替换为实际值。

curl -X POST "https://modelstudio.cn-beijing.aliyuncs.com/tokenplan/invite/link/create?ExpireType=DAYS_7&SsoSource=SAML" \
    --header "x-acs-action: CreateTokenPlanInviteLink" \
    --header "x-acs-version: 2026-02-10" \
    --header "x-acs-date: 2026-01-01T12:00:00Z" \
    --header "x-acs-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" \
    --header "x-acs-signature-nonce: ${SIGNATURE_NONCE}" \
    --header "Authorization: ACS3-HMAC-SHA256 Credential=${ALIBABA_CLOUD_ACCESS_KEY_ID},SignedHeaders=host;x-acs-action;x-acs-content-sha256;x-acs-date;x-acs-signature-nonce;x-acs-version,Signature=${SIGNATURE}"
import os

from alibabacloud_modelstudio20260210.client import Client
from alibabacloud_modelstudio20260210 import models
from alibabacloud_tea_openapi import models as open_api_models

config = open_api_models.Config(
    access_key_id=os.environ["ALIBABA_CLOUD_ACCESS_KEY_ID"],
    access_key_secret=os.environ["ALIBABA_CLOUD_ACCESS_KEY_SECRET"],
    endpoint="modelstudio.cn-beijing.aliyuncs.com",
)
client = Client(config)

request = models.CreateTokenPlanInviteLinkRequest(
    expire_type="DAYS_7",
    sso_source="SAML",
)
response = client.create_token_plan_invite_link(request)
print(response.body)
import com.aliyun.auth.credentials.Credential;
import com.aliyun.auth.credentials.provider.StaticCredentialProvider;
import com.aliyun.sdk.service.modelstudio20260210.AsyncClient;
import com.aliyun.sdk.service.modelstudio20260210.DefaultAsyncClientBuilder;
import com.aliyun.sdk.service.modelstudio20260210.models.CreateTokenPlanInviteLinkRequest;
import com.aliyun.sdk.service.modelstudio20260210.models.CreateTokenPlanInviteLinkResponse;

public class CreateTokenPlanInviteLink {
    public static void main(String[] args) throws Exception {
        StaticCredentialProvider provider = StaticCredentialProvider.create(Credential.builder()
            .accessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
            .accessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"))
            .build());
        AsyncClient client = new DefaultAsyncClientBuilder()
            .credentialsProvider(provider)
            .region("cn-beijing")
            .build();

        CreateTokenPlanInviteLinkRequest request = CreateTokenPlanInviteLinkRequest.builder()
            .expireType("DAYS_7")
            .ssoSource("SAML")
            .build();
        CreateTokenPlanInviteLinkResponse response = client.createTokenPlanInviteLink(request).get();
        System.out.println(response.getBody());
        client.close();
    }
}

返回示例

{
  "Success": true,
  "Data": {
    "Token": "sk-ws-D.****.*******"
  }
}

错误码

如果调用失败,会返回错误信息。更多错误码及解决方法,请参见Token Plan API 错误码。