---
metadata:
  - name: generator
    content: Diplodoc Platform v5.44.0
alternate:
  - https://yandex.com/dev/id/doc/en/mobileauthsdk/android/archive/3.1.0/sdk-android-methods.md
  - https://yandex.com/dev/id/doc/ru/mobileauthsdk/android/archive/3.1.0/sdk-android-methods.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/id/doc/en/llms.txt

# Function guide

## YandexAuthsdk Class {#yaloginsdk}

Authorization class.

### Properties and functions {#yaloginsdk-methods}

* A contract for starting a SDK Yandex ID activity.

   It's meant to be used with the `registerForActivityResult()` function as described in the [documentation](https://developer.android.com/training/basics/intents/result). `YandexAuthLoginOptions` is taken as input parameters. `Result<YandexAuthToken?>` is returned.

   ```java
   val contract: YandexAuthSdkContract
   ```

* Obtaining a [JSON Web Token](https://yandex.com/dev/id/doc/en/tokens/jwt.md).

   ```java
   fun getJwt(token: YandexAuthToken): String
   ```


## YandexAuthSdkContract class {#yaloginsdkconfig}

The SDK Yandex ID configuration class. 

### Properties and functions {#yaloginsdkconfig-methods}

* Creating a SDK Yandex ID configuration. The client app ID is taken from `build.gradle`.

   ```java
   YandexAuthOptions(context: Context, loggingEnabled: Boolean = false)
   ```

   where `loggingEnabled` is a flag that indicates whether logging messages from SDK Yandex ID is allowed.

* Getting the [app ID](https://yandex.com/dev/id/doc/en/register-client.md#app-params).

   ```java
   val clientId: String
   ```

* Getting the flag that indicates whether logging messages from SDK Yandex ID is allowed.

   ```java
   val isLoggingEnabled: Boolean
   ```


## YandexAuthLoginOptions Class {#yandexauthloginoptions}

An authorization parameters class. You need to pass an instance of this class to the `launch()` method when starting the authorization process.

### Properties and functions {#yandexauthloginoptions-methods}

* Creating an instance of the `YandexAuthLoginOptions` class.

   ```java
   YandexAuthLoginOptions(val loginType: LoginType = LoginType.NATIVE)
   ```

   where `LoginType` determines the user authorization mode.

   Possible modes:

   * `NATIVE` — A Yandex app that supports authorization is used. Here are these apps:
      
      * Yandex Browser
      * Yandex Start
      * Yandex with Alice
      * Yandex Go
      * Yandex Mail
      * Yandex Disk
      * Yandex Pay
      * Yandex Key

      If no app from the list is installed on the device, a Chrome Tab of the default browser opens during the authorization. If the default browser doesn't support Chrome Tabs, a [WebView](https://developer.android.com/develop/ui/views/layout/webapps/webview) opens.

   * `CHROME_TAB` — A Chrome Tab of the device's default browser is used. If the default browser doesn't support Chrome Tabs, a [WebView](https://developer.android.com/develop/ui/views/layout/webapps/webview) opens.

   * `WEBVIEW` — [WebView](https://developer.android.com/develop/ui/views/layout/webapps/webview) is used.

* Getting the user authorization mode passed in the constructor.

   ```java
   val loginType: LoginType
   ```


## YandexAuthResult interface {#result}

The result that SDK Yandex ID returns after the authorization. A "sealed interface" that has three possible inheritors.

### Descendants {#result-instances}

* Successful authorization.

   ```java
   data class Success(val token: YandexAuthToken) : YandexAuthResult
   ```
   
   where `token` is the token issued during the successful authorization.

* Failed authorization.

   ```java
   data class Failure(val exception: YandexAuthException) : YandexAuthResult
   ```
   
   where `exception` is an error that occurred during the authorization.

* Authorization canceled by the user.

   ```java
   object Cancelled : YandexAuthResult
   ```


## YandexAuthToken Class {#token}

The class that SDK Yandex ID returns after a successful authorization.

### Properties and functions {#token-methods}

* Creating a token and getting information about its value, type, and lifetime.

   ```java
   class YandexAuthToken(val value: String, val expiresIn: Long)
   ```

* Getting the token value.

   ```java
   val value: String
   ```

* Getting the token lifetime.
   
   ```java
   val expiresIn: Long
   ```
