Skip to main content

sber_id_login 0.1.2 copy "sber_id_login: ^0.1.2" to clipboard
sber_id_login: ^0.1.2 copied to clipboard

Sber ID sign-in for Flutter: iOS on top of SIDSDK, Android on top of io.github.sid-sdk:SIDSDK_CORE.

sber_id_login #

Sber ID sign-in for Flutter apps: iOS on top of SIDSDK, Android on top of io.github.sid-sdk:SIDSDK_CORE.

What it does #

It returns the authorization code and stops there. Exchanging the code for tokens is the backend's responsibility: the exchange requires a client_secret and a client mTLS certificate.

Requirements #

Platform Minimum
Android minSdk 24
iOS iOS 14.0

SDK versions: io.github.sid-sdk:SIDSDK_CORE:1.6.1 on Android, SIDSDK/SIDSDKStatic ~> 1.6.0 on iOS.

Usage #

await SberIdLogin.instance.initialize(const SberIdLoginConfig(
  clientId: '...',               // from the Sber ID console
  redirectUri: 'myapp://sberid', // registered with Sber in advance
  partnerName: 'My app',
  scopes: ['openid', 'email', 'phone'],
));

final response = await SberIdLogin.instance.login();
// You can pass your own codeVerifier: login(codeVerifier)
if (response?.isSuccess == true) {
  // response.authCode, response.state, response.nonce, response.codeVerifier
  // go to the backend, which returns the app session
}

The following methods are also available: isSberIdInstalled(), generateCodeVerifier(), and logout().

Example #

See example/ for a runnable app that initializes the plugin, starts sign-in, checks whether SberBank Online is installed, generates a PKCE verifier, and logs out.

How Android sign-in works #

If SberBank Online is installed, the flow switches seamlessly to the bank app; otherwise it uses Custom Tabs. Both paths deliver the result to the same activity, so a single handler covers them. PKCE can be supplied by the app; otherwise the verifier is generated via PkceUtils. state and nonce are returned from Sber's response (if Sber does not provide them, the values generated at login start are used).

The plugin manifest declares a <queries> entry for ru.sberbankmobile: on Android 11 and later, without it the "is the bank installed" check always returns false, and seamless sign-in silently degrades to the browser.

How iOS sign-in works #

The native SIDSDK is used. During initialization the plugin calls SID.initializer.initialize(stand: .prom) and SID.settings.applyMainPreferences(clientID:userID:partnerName:partnerProfileUrl:).

During login the plugin uses the supplied codeVerifier or generates one via SIDUtils.createVerifier, derives the challenge via SIDUtils.createChallenge, builds a SIDAuthRequest (scope, state, nonce, redirectUri, codeChallenge), and calls SID.login.auth(request:viewController:). The SDK opens its own authorization screen.

After a successful authorization Sber redirects to redirectUri via a URL scheme. The plugin intercepts that URL in application(_:open:options:), passes it to SID.login.getResponseFrom(url), and returns authCode, state, nonce, and codeVerifier to Flutter.

The "is SberBank installed" check uses canOpenURL with the sberbankidexternallogin:// and sbolidexternallogin:// schemes.

What the package does not include #

A sign-in button. Sber regulates its appearance in a separate guideline, and it is easier to build in the app where fonts and corner radii are known.

3
likes
150
points
764
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Sber ID sign-in for Flutter: iOS on top of SIDSDK, Android on top of io.github.sid-sdk:SIDSDK_CORE.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on sber_id_login

Packages that implement sber_id_login