Instructor Single Sign-On
Feature Overview
Single sign-on allows direct login to an existing system, enabling access to the Interactive Classroom backend without a separate login process to configure live streaming settings.
Applicable Scenario
Single sign-on from Interactive Classroom to the instructor's teaching page.
Interface Flow
设置登录token --> 在讲师登录地址加上登录token和老师Id --> 上课页面
1. Set Token
Interface Description
1、讲师单点登录设置token接口
2、(timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议
Interface URL
http://api.polyv.net/hi-class-api/open/teach/v1/set-token
Request Method
POST
Interface Constraints
- The interface supports both HTTP and HTTPS. HTTPS is recommended to ensure interface security. Interface calls are subject to frequency limits. Click for details
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | true | String | Account appId See: Get Secret Key |
| timestamp | true | Long | Current 13-digit millisecond timestamp, valid for 3 minutes |
| sign | true | String | Signature, a 32-character uppercase MD5 value See: Signature Generation Rules |
Request Body Parameter Description
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| teacherId | true | String | Instructor ID (teacherId) |
| token | true | String | Single sign-on token, one-time use, valid for 1 hour |
Example
http://api.polyv.net/hi-class-api/open/teach/v1/set-token?appId=frlr1zazn3&sign=6387F30E550150DD7A1AB11376137A6E×tamp=1634631207876
Request Body Parameters
{
"teacherId": "g3fdl05syf",
"token": "269gH563903OSUwylnAT"
}
Response Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Response status code, 200 for success, non-200 for failure See: Global Error Description |
| status | String | Response status text |
| error | Error | Error object See: Global Error Description |
| data | Object | Empty on success or failure See: data field description |
data Field Description
| Parameter | Type | Description |
|---|---|---|
| status | Boolean | Success: true, Failure: false |
Java Request Example
For quick integration of the base code, download the relevant dependency source code. Click to download source code. After downloading, add it to your own project source code. HttpUtil.java and LiveSignUtil.java from the test cases are included in the download file.
private static final Logger log = LoggerFactory.getLogger(VClassSSOTest.class);
/**
* 讲师单点登录
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void tokenLogin() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/hi-class-api/open/teach/v1/set-token";
String teacherId = "g3fdl05syf";
String token = getRandomString(20);
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("teacherId", teacherId);
jsonMap.put("token", token);
url = HttpUtil.appendUrl(url, requestMap);
String response = HttpUtil.postJsonBody(url, JSON.toJSONString(jsonMap), null);
log.info("测试讲师单点登录成功:{}", response);
//do somethings
}
Response Example
For system global error descriptions, see Global Error Description
Success Example
{
"code": 200,
"status": "success",
"requestId": "5bc5c3a4a88a487192cb0256b1dadb7f.97.16346312121920507",
"data": null,
"success": true
}
Error Example
{
"code": 400,
"status": "error",
"data": "",
"error":{"code":xx,"desc":"错误描述"}
}
2. Construct URL for Login
Direct Login
After setting the instructor login token via the API above, construct the URL as follows:
https://s.vclass.com/live-web-hi-class/teacher/tokenLogin?teacherId=xxxx&token=ssss&lessonId=101
URL Parameter Description
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| teacherId | true | String | Instructor ID (teacherId) |
| token | true | String | Single sign-on token, one-time use, valid for 1 hour |
| lessonId | false | Integer | Optional parameter. If provided, it navigates to the corresponding lesson; otherwise, the lesson list is displayed by default. |
Response Description
Upon successful login, the instructor page is displayed directly.
Relevant prompts will be shown on the login page in case of errors.
