Using the SDK

Set up your app to receive tokens by following these steps:

1. Initialization

In your app's build.gradle, add:

android {
        defaultConfig {
        manifestPlaceholders = [YANDEX_CLIENT_ID:"<Client id of you application>"]

Use this code for initialization:

final YandexAuthSdk sdk = new YandexAuthSdk(requireContext(), new YandexAuthOptions.Builder(requireContext())
                .enableLogging() // Only in testing builds

2. Authorization

To enable authorization, use the following method:

final YandexAuthLoginOptions.Builder loginOptionsBuilder =  new YandexAuthLoginOptions.Builder();
final Intent intent = sdk.createLoginIntent(;

To receive authorization events, override the following method:

protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        if (requestCode == REQUEST_LOGIN_SDK) {
            try {
                final YandexAuthToken yandexAuthToken = sdk.extractToken(resultCode, data);
                if (yandexAuthToken != null) {
                    // Success auth
            } catch (YandexAuthException e) {
                // Process error
    super.onActivityResult(requestCode, resultCode, data);

3. Getting a JSON Web Token

To get a JSON Web Token, use the following method:


Error codes

Error codes are described in the Error codes section.