tinkoff_id_flutter

Creator: coderz1093

Last updated:

0 purchases

tinkoff_id_flutter Image
tinkoff_id_flutter Images

Languages

Categories

Add to Cart

Description:

tinkoff id flutter

tinkoff_id_flutter #
Tinkoff ID Native Android And iOS SDK Flutter Realization
Features #
The plugin allows you:

to receive a set of social tokens from the Tinkoff ID system of Tinkoff Bank.
update token via refreshToken
logout from Tinkoff ID

Getting started #
Android requirements:

minSdkVersion >= 21

Usage #
Add to Info.plist in your app so your app can open Tinkoff Bank App:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>tinkoffiddebug</string>
<string>tinkoffbank</string>
</array>
copied to clipboard
Add to Info.plist in your app so Tinkoff Bank App can open your app with incoming link:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>tru</string> /// scheme
<string>redirecturi</string> ///host
</array>
</dict>
</array>
copied to clipboard
Use all methods of in your app:
class SignInWithTinkoffIdUseCase {
final TinkoffIdFlutter _tinkoffId;

SignInWithTinkoffIdUseCase(this._tinkoffId);

Future<Result<List<String>>> getTokenFromTinkoffId() async {
const redirectUri = "rdu://rduhost";
const clientId = "tid_client_id";

///Init client
await _tinkoffId.init(clientId, redirectUri, false);

///Check whether app installed or not
final bool isAvailable = await _tinkoffId.isTinkoffAuthAvailable();
if (!isAvailable) {
return Result.failure("Tinkoff Bank application not found or not installed.");
}

///Start listen first link
final appLinkFuture = AppLinks().stringLinkStream.first;

///Launch Tinkoff Bank App
await _tinkoffId.startTinkoffAuth(redirectUri);

///Wait for first incoming link
late final String url;
try {
url = await appLinkFuture.timeout(seconds(120));
} catch (e) {
return Result.failure("120 seconds have passed, but the link has not arrived.");
}
///Get token from incoming link
late final TokenPayload payload;
try {
payload = await _tinkoffId.getTokenPayload(url);
} on PlatformException catch (e, s) {
return Result.failure("Failed to get token from Tinkoff Bank app: ${e.message!}");
}

///Update tokens by refreshToken
late final TokenPayload payloadNew;
try {
payloadNew = await _tinkoffId.updateToken(payload.refreshToken);
} on PlatformException catch (e, s) {
return Result.failure("Failed to exchange refresh token for access token: ${e.message!}");
}

///Sign out by refresh token
final bool success = await _tinkoffId.signOutByRefreshToken(payloadNew.refreshToken);
if (!success) {
return Result.failure("Failed to log out.");
}

return Result.success([
payload.accessToken,
payload.refreshToken,
payloadNew.accessToken,
payloadNew.refreshToken
]);
}
}
copied to clipboard
Additional information #
For more information, support, or to report bugs or suggest new features.
https://github.com/kodefabrique/tinkoff_id_flutter

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.