The translation was generated automatically and may contain mistakes
Captcha connection and auto-processing
The instructions describe how to install and connect the VK ID Captcha SDK for an Android application, as well as how to configure the captcha display and the processing of results using an interseptor:
- 1.
- 2.
- 3.
Requirements
Android platform, API level — 21 or new: android:minSdkVersion="21" .
Step 1. Connecting the repository
For integration, use the maven repository:
maven {
url("https://artifactory-external.vkpartner.ru/artifactory/vkid-sdk-android/")
}Step 2. Dependency setting
Connect the VK ID Captcha SDK to Android. Current version ${sdkVersion} = 0.0.5 .
dependencies {
implementation "com.vk.id.captcha:vkid-captcha:${sdkVersion}"
}B. Android Manifest Override your application authority A provider that initializes the SDK.
<application>
<provider
android:name="com.vk.id.captcha.init.SdkInitContentProvider"
android:authorities="your.unique.authority"
android:exported="false"
tools:replace="authorities" />
</application>Step 3. Captcha mapping and processing
After connecting the VK ID Captcha SDK of Android, integrate the captcha in one of the following ways:
- •Using the Interseptor It is recommended if you use
OkHttp. - •Using listener interfaces A backup option if you are not using it.
OkHttp.
Regardless of the integration method (interceptor or listener interface), captcha processing includes two types of errors that the VKontakte API can return:
- •captcha Error
14It contains"error_code": 14,"error_msg": "Captcha needed"and a reference to initialize the captcha session in the fieldredirect_uri. - •заголовки
X-Challenge-SolutionandX-Challenge-Url— contain a link to initialize the captcha session.
Using Interceptors (Recommended)
This method of integration is suitable if you use OkHttp .
Add an interceptor that is implemented in the VK ID Captcha SDK of Android:
OkHttpClient.Builder()
...
.addInterceptor(
CaptchaHandlingInterceptor(
domains = setOf("api.vk.ru") // Список доменов, для которы?1?… должна обрабатываться ошибка капчи (опционально). По умолчанию обрабатываются все домены
)
)
...
.build()If this interceptor is not like you, you can implement their own .