Integrating Odnoklassniki API in a Mobile Application
Odnoklassniki (OK.ru) is the second-largest Russian-speaking social network. Audience skews 35+, relevant for retail, media, family services apps. API called OK API, standard OAuth flow, but request signing differs from VKontakte.
App Registration and Keys
Register on dev.ok.ru, get three keys: application_id, application_key (public), application_secret_key (private, server-only). App type—"Mobile."
Authorization: OAuth 2.0 + Request Signing
Authorize via WebView or system browser:
https://connect.ok.ru/oauth/authorize
?client_id=YOUR_APP_ID
&scope=GET_EMAIL;VALUABLE_ACCESS;PHOTO_CONTENT
&response_type=code
&redirect_uri=yourapp://oauth
After receiving code—exchange for access_token via POST to https://api.ok.ru/oauth/token.do.
Request Signing
Key difference from OK API. Each request is signed:
sig = MD5(params_sorted_alphabetically + MD5(access_token + application_secret_key))
Steps:
- Take all request params except
sigandaccess_token. - Sort by param name, concatenate to string
key=value. - Calculate
session_secret = MD5(access_token + application_secret_key)—server-side, secret not to client. -
sig = MD5(params_string + session_secret).
Never send application_secret_key to client—through backend proxy only. Architecture: client requests your backend → backend adds signature → proxies request to OK API.
OK SDK for Mobile
iOS: OKLoginSDK via CocoaPods or SPM (unofficial). No official maintained Swift SDK—usually implement OAuth flow manually via ASWebAuthenticationSession.
Android: Official ok-android-sdk on GitHub. Gradle:
implementation 'ru.ok.android:sdk:3.0.18'
Authorization:
OkAuthManager.startOkAutoExternal(activity, listOf(OkScope.GET_EMAIL, OkScope.VALUABLE_ACCESS))
// In onActivityResult:
val token = OkAuthManager.onActivityResult(requestCode, resultCode, data, listener)
Getting User Data
GET https://api.ok.ru/fb.do
?method=users.getCurrentUser
&fields=NAME,PIC_1,LOCATION,EMAIL,GENDER
&access_token=...
&application_key=...
&sig=...
&format=json
Profile fields differ from VK: NAME—name, LAST_NAME—last name, PIC_1—50x50 avatar, PIC_3—128x128 avatar. Email returned only with GET_EMAIL scope and if user entered it.
Publishing to OK
Scope VALUABLE_ACCESS required for publishing. Publish via mediatopic.post:
POST https://api.ok.ru/fb.do
method=mediatopic.post
&type=USER_STATUS
&attachment={"media":[{"type":"text","text":"Post text"}]}
For publishing with photo: upload via photosV2.getUploadUrl, then use photo token in attachment.
Errors
-
PARAM_SESSION_EXPIRED—token expired. OK tokens live 30-60 days, refresh token—longer. -
PERMISSION_DENIED—insufficient scope. -
SERVICE_UNAVAILABLE—API temporarily unavailable, retry with exponential backoff.
Timeline
OK authorization + profile import with backend signature proxy: 2–3 days. Publishing with media: +1 day. Pricing calculated individually.







