Skip to content

登录指定用户

生成授权后的客户端url(登录)

接口信息

  • 接口: /user/{id}/authorize
  • 请求方式: POST

路由参数

参数类型示例解释必填
idstring5832d184-dd53-42a0-8ace-0bf8d660f4cc用户 id(主账号)

请求参数

参数类型示例解释
sub_user_idstring91f9254f-ca58-49af-be34-8370d7549d73子账户 id(传递此参数则是对子账户操作)

请求示例

cURL
curl -X POST "https://ai.api.longlonglong.cn/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/authorize" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "sub_user_id": "91f9254f-ca58-49af-be34-8370d7549d73"
  }'
Go
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
)

func main() {
    url := "https://ai.api.longlonglong.cn/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/authorize"
    data := map[string]string{
        "sub_user_id": "91f9254f-ca58-49af-be34-8370d7549d73",
    }
    jsonData, _ := json.Marshal(data)

    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("Authorization", "Bearer YOUR_TOKEN")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
JavaScript
const id = "5832d184-dd53-42a0-8ace-0bf8d660f4cc";
const url = `https://ai.api.longlonglong.cn/user/${id}/authorize`;
const data = {
  sub_user_id: "91f9254f-ca58-49af-be34-8370d7549d73"
};

fetch(url, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN"
  },
  body: JSON.stringify(data)
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error("Error:", error));
Java
import java.net.URI;
import java.net.http.*;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException, InterruptedException {
        HttpClient client = HttpClient.newHttpClient();
        String body = "{\"sub_user_id\":\"91f9254f-ca58-49af-be34-8370d7549d73\"}";
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://ai.api.longlonglong.cn/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/authorize"))
            .header("Content-Type", "application/json")
            .header("Authorization", "Bearer YOUR_TOKEN")
            .POST(HttpRequest.BodyPublishers.ofString(body))
            .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
PHP
<?php

$curl = curl_init();

$data = [
    "sub_user_id" => "91f9254f-ca58-49af-be34-8370d7549d73"
];

curl_setopt_array($curl, [
    CURLOPT_URL => "https://ai.api.longlonglong.cn/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/authorize",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => json_encode($data),
    CURLOPT_HTTPHEADER => [
        "Content-Type: application/json",
        "Authorization: Bearer YOUR_TOKEN"
    ],
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
Python
import requests
import json

user_id = "5832d184-dd53-42a0-8ace-0bf8d660f4cc"
url = f"https://ai.api.longlonglong.cn/user/{user_id}/authorize"

data = {
    "sub_user_id": "91f9254f-ca58-49af-be34-8370d7549d73"
}

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN"
}

response = requests.post(url, data=json.dumps(data), headers=headers)

print(response.json())
C++
#include <iostream>
#include <curl/curl.h>
#include <string>

size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp) {
    ((std::string*)userp)->append((char*)contents, size * nmemb);
    return size * nmemb;
}

int main() {
    CURL* curl;
    CURLcode res;
    std::string readBuffer;

    curl = curl_easy_init();
    if(curl) {
        struct curl_slist* headers = NULL;
        headers = curl_slist_append(headers, "Content-Type: application/json");
        headers = curl_slist_append(headers, "Authorization: Bearer YOUR_TOKEN");

        const char* data = "{\"sub_user_id\":\"91f9254f-ca58-49af-be34-8370d7549d73\"}";

        curl_easy_setopt(curl, CURLOPT_URL, "https://ai.api.longlonglong.cn/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/authorize");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);

        res = curl_easy_perform(curl);
        if(res != CURLE_OK)
            fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
        else
            std::cout << readBuffer << std::endl;

        curl_easy_cleanup(curl);
    }
    return 0;
}

返回内容

注意:快捷登录地址固定http协议,需要https可以自行截取替换

json
{
    "code": 200,
    "status": "success",
    "message": "生成成功",
    "data": {
        "url": "http://saas.ai.com/quick-login?token=NmFlMTUzMzQtY2YwNy00NTMzLTg4OTAtNDY1NzZmZTNmNzZi"
    }
}

data 中的 url 为登录地址,如果你的OEM地址不是saas.ai.com这个域名,请自行将token取出,拼接成{domain}/quick-login?token=token的形式登录;

此token有效期为1分钟

该 url 地址可作为iframe的形式嵌入您的站点,为您提供能力(注意:iframe地址的协议请和您嵌入的协议一致,否则会登录失败)

该 url 地址可自行拼接 string 类型的 remark 参数,拼接为 {domain}/quick-login?token=token&remark=remark 的形式,该参数可在操作日志中展示且支持模糊查询

该 url 地址可自行拼接 string 类型的 redirect 参数,如 {domain}/quick-login?token=token&redirect=/workbench/outbound,将在登录成功后,跳转到呼叫中台-AI外呼

基于 MIT 许可发布