Function guide

YandexAuthSdk class

The authorization class.

Properties and functions

  • A contract for starting a SDK Yandex ID activity.

    It's meant to be used with the registerForActivityResult() function as described in the documentation. YandexAuthLoginOptions is taken as input parameters. Result<YandexAuthToken?> is returned.

    val contract: YandexAuthSdkContract
    
  • Obtaining a JSON Web Token.

    fun getJwt(token: YandexAuthToken): String
    

YandexAuthSdkContract class

The SDK Yandex ID configuration class.

Properties and functions

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

    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.

    val clientId: String
    
  • Getting the flag indicating that logging messages from SDK Yandex ID is allowed.

    val isLoggingEnabled: Boolean
    

YandexAuthLoginOptions class

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

Properties and functions

  • Creating an instance of the YandexAuthLoginOptions class.

    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 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 opens.

    • WEBVIEWWebView is used.

  • Getting the user authorization mode passed in the constructor.

    val loginType: LoginType
    

YandexAuthResult interface

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

Descendants

  • Successful authorization.

    data class Success(val token: YandexAuthToken) : YandexAuthResult
    

    where token is the token issued during the successful authorization.

  • Failed authorization.

    data class Failure(val exception: YandexAuthException) : YandexAuthResult
    

    where exception is an error that occurred during the authorization.

  • Authorization canceled by the user.

    object Cancelled : YandexAuthResult
    

YandexAuthToken class

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

Properties and functions

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

    class YandexAuthToken(val value: String, val expiresIn: Long)
    
  • Getting the token value.

    val value: String
    
  • Getting the token lifetime.

    val expiresIn: Long
    
Previous