External JavaScript SDK

Github repository: ok-js-sdk
SDK sample apps: ok-js-sdk/samples

External JavaScript SDK is SDK for MOBILE_HTML applications and external browser-based apps. It can be used for client OAuth authorization for external applications, to invoke UI payment methods (just as JS SDK) for MOBILE_HTML applications, publish topics to user’s wall via publishing widget, send notifications or invite users to a game, and to invoke REST API methods.

Before setting up External SDK check your application’s settings:

  • MOBILE_HTML or External platform should be enabled;
  • for MOBILE_HTML apps:
    • callback url must be specified for payments to work correctly;
  • for External apps:
    • client OAuth authorization is enabled;
    • redirect_uri field contains an url that will be used for authorization process;
    • all required permissions are enabled. It is highly recommended to enable LONG_ACCESS_TOKEN permission for native IOS and Android applications.

To enable External SDK in your project you need to: * copy oksdk.js file from repository to your project; * enable this script on your page, i.e:

<script type="text/javascript" src="oksdk.js"></script>


To correctly init SDK specify your application’s id and key in a config:

var config = {
    app_id: 0,
    app_key: ''
OKSDK.init(config, function () {
    //on success
}, function (error) {
    //on error

To invoke REST API method use OKSDK.REST.call:

OKSDK.REST.call("METHOD_NAME", { fields: "FIELDS"}, function (status, data, error) {

To use our widgets use the following methods:

OKSDK.Widgets.post(RETURN_URL, JSON.stringify({"media": [{"type": "text", "text": "hello world!"}]}));

Payment example for MOBILE_HTML application

To initiate a payment you need to open a following URL:


Methods parameters:

nameYesStringProduct name. I.e. “1 apple”
priceYesintProduct price in OKs
codeYesStringProduct identifier. It is a string that contains information about product, it’s price and all other data required for verification. Code is sent to application server during payment processing.

Signature calculation

Signature is calculated by the following formula:

md5(“application_key=” + APPLICATION_PUBLIC_KEY + “code=”+PRODUCT_CODE + “name=” + PRODUCT_NAME + “price=” + PRODUCT_PRICE + “session_key=” + SESSION_KEY + SESSION_SECRET_KEY)

Payment with SDK

SDK allows you to proceed payments in an easy and fast way:

OKSDK.Payment.show(productName, productPrice, productCode)

If a payment was accepted or canceled by user he is then redirected to an application page. Additional GET-parameter “custom_args” is added to an URL with value “payment=ok” if payment was proceeded successfully and “payment=cancel” if it was cancelled.