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:

YandexAuthSdk sdk = new YandexAuthSdk(getContext(), new YandexAuthOptions(getContext(), true));

2. Authorization

To enable authorization, use the following method:

startActivityForResult(sdk.createLoginIntent(context, scopes), REQUEST_CODE_YA_LOGIN);

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.