Basic Commands
The SDK commands below are designed to conduct basic SDK operations:
Set API domain
Sets the SDK to use your back-end's domain name. Please head to https://app.vpnwholesaler.com/credentials in order to retrieve your API base domain name.
Please use the domain name only without scheme (i.e. do not include https://)
Login required: No
CmdProc Code: OVS_CMD_SET_API_DOMAIN
Command number: 9
Input:
{
"api_domain": "your_subdomain.vpngn.com",
"csid": "your_client_side_api_key"
}
Response: OVS_NOTIFY_SET_API_DOMAIN
OVS_NOTIFY_SET_API_DOMAIN Successful response OVS_ERR_OK data is null
Code sample:
- Java
- Kotlin
- Json
VPNSDK.CommandNotifyCB callback = new VPNSDK.CommandNotifyCB() {
@Override
public void onNotify(int notification, int error, Object data) {
if (error == VPNSDK.OVS_ERROR_CODES.OVS_ERR_OK) {
// Do something when command is successful
} else {
// Process error
}
}
};
VPNSDK.CmdProc(VPNSDK.OVS_CMD_CODES.OVS_CMD_SET_API_DOMAIN, callback, your_subdomain, your_csid);
val callback = object : VPNSDK.CommandNotifyCB {
override fun onNotify(notification: Int, error: Int, data: Any?) {
if (error == VPNSDK.OVS_ERROR_CODES.OVS_ERR_OK) {
// Do something when command is successful
} else {
// Process error
}
}
}
VPNSDK.CmdProc(VPNSDK.OVS_CMD_CODES.OVS_CMD_SET_API_DOMAIN, callback, "your_subdomain", "your_client_side_api_key")
VPNSDK.CmdProc("{\"cmd\": 9, \"data\" : { \"api_domain\" : \"your_subdomain\", \"csid\" : \"your_csid\"}}");
Login
Logins to the back-end and retrieves active products associated with the given user.
Login required: No
CmdProc Code: OVS_CMD_LOGIN
Command number: 1
Input:
Username and Pasword
{
"username": "end_user_email_address",
"password": "end_user_password"
}
end_user_email_address - End-user's username end_user_password - End-user's password
Short token
"username": "$$short_token$$",
"password": "user_short_token"
user_short_token - End user's short token
Response: OVS_NOTIFY_LOGIN
OVS_NOTIFY_LOGIN Successful response
OVS_ERR_OK
Data contains information about user account and account status:
nextduedate - Plan renewal date
username - OpenVPN username
password - OpenVPN password
status - Account status
name - User's first name
email - User's email address
debug - Debug mode?
free - Free plan?
OVS_NOTIFY_LOGIN Failed response
OVS_ERR_WEB_API
OVS_ERR_RESP_INVALID
OVS_ERR_LOGIN_FAILED
OVS_ERR_NO_ACTIVE_PLAN - after receiving this response it is still possible to use user management functions.
However, VPN functions are unavailable until the end-user is logged-in with an active plan (it is recommended to invoke Logout method before logging-in).
data contains a human readable error description
Code sample:
- Java
- Kotlin
- JSON
VPNSDK.CommandNotifyCB callback = new VPNSDK.CommandNotifyCB() {
@Override
public void onNotify(int notification, int error, Object data) {
if (error == VPNSDK.OVS_ERROR_CODES.OVS_ERR_OK) {
// Do something when command is successful
} else {
// Process error
}
}
};
VPNSDK.CmdProc(VPNSDK.OVS_CMD_CODES.OVS_CMD_LOGIN, callback, "username", "password");
val callback = object : VPNSDK.CommandNotifyCB {
override fun onNotify(notification: Int, error: Int, data: Any?) {
if (error == VPNSDK.OVS_ERROR_CODES.OVS_ERR_OK) {
// Do something when command is successful
} else {
// Process error
}
}
}
VPNSDK.CmdProc(VPNSDK.OVS_CMD_CODES.OVS_CMD_LOGIN, callback, "username", "password")
VPNSDK.CmdProc("{\"cmd\" : 1, \"data\" : {\"username\": \"username\", \"password\": \"password\"}}");
Logout
Logs out a currently logged-in end-user.
Login required: Yes
CmdProc Code: OVS_CMD_LOGOUT
Command number: 38
Input: Not required
Response: OVS_NOTIFY_LOGOUT
OVS_NOTIFY_LOGOUT Successful response OVS_ERR_OK data is null
OVS_NOTIFY_LOGOUT Failed response OVS_ERR_LOGOUT data contains a human readable error description
Code sample:
- Java
- Kotlin
- JSON
VPNSDK.CommandNotifyCB callback = new VPNSDK.CommandNotifyCB() {
@Override
public void onNotify(int notification, int error, Object data) {
if (error == VPNSDK.OVS_ERROR_CODES.OVS_ERR_OK) {
// Do something when command is successful
} else {
// Process error
}
}
};
VPNSDK.CmdProc(VPNSDK.OVS_CMD_CODES.OVS_CMD_LOGOUT, callback);
val callback = object : VPNSDK.CommandNotifyCB {
override fun onNotify(notification: Int, error: Int, data: Any?) {
if (error == VPNSDK.OVS_ERROR_CODES.OVS_ERR_OK) {
// Do something when command is successful
} else {
// Process error
}
}
}
VPNSDK.CmdProc(VPNSDK.OVS_CMD_CODES.OVS_CMD_LOGOUT, callback)
VPNSDK.CmdProc("{\"cmd\": 38}");