Get ctoken for use with Lovense Pattern Editor initialization
API
API URL: https://api.lovense-api.com/api/media/pattern/user/ctoken?userId={userId}&developerToken={developerToken}
Request Protocol: HTTPS Request
Method: GET
Parameters:
Parameters | Description | Type | Required |
---|---|---|---|
userId | Your user's ID from your platform. userId can be a combination of letters/numbers/hyphen/underscore with length of 6-32 characters. When the same user opens multiple tabs or refreshes a web page, the userId needs to be kept constant. | string | Yes |
developerToken | Find this from the Lovense Developer dashboard | string | Yes |
Response Content Type: application/json
Response:
name | type | description |
---|---|---|
ctoken | string | Used for video pattern initialization. The ctoken is valid for 24 hours. If it is expired, you will receive an error message. |
Request Example:
Sample response:
{
"result": true,
"code": 0,
"message": "success",
"data": {
"ctoken": "ug2SHv710OfZCkKH90-E4N-so_Gkv_ihj-m4pvNqp6J6VxGLu5zCwXh1n_FrayAeFDXlOzWw"
}
}
⚠️ For security reasons, to avoid
Developer Token
exposure we recommend to perform such requests from server side only, not from the client side.
Example
// <dependency>
// <groupId>org.apache.httpcomponents</groupId>
// <artifactId>httpclient</artifactId>
// <version>4.5.10</version>
// </dependency>
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
public class HttpClientExample {
public static void main(String[] args) throws IOException {
CloseableHttpClient httpClient = HttpClients.createDefault();
try {
HttpGet request = new HttpGet("https://api.lovense-api.com/api/media/pattern/user/ctoken?userId=[userId]&developerToken=[developerToken]");
CloseableHttpResponse response = httpClient.execute(request);
try {
// 200
System.out.println(response.getStatusLine().getStatusCode());
HttpEntity entity = response.getEntity();
if (entity != null) {
// return it as String
String result = EntityUtils.toString(entity);
// json result
System.out.println(result);
}
} finally {
response.close();
}
} finally {
httpClient.close();
}
}
}