모바일 애플리케이션용으로 VK.com 로그인 통합을 원활하게 제공하는 플러터 패키지입니다. VK의 OAuth 흐름을 처리하여 인증 프로세스를 간소화하고 사용자가 자신의 VK 계정으로 로그인할 수 있도록 합니다. 이름, 이메일, 프로필 사진과 같은 핵심 사용자 프로필 정보를 가져와 사용자 경험을 개인화하기 쉽게 만듭니다. 안드로이드 및 iOS 전용으로 설계되어 기존 플러터 프로젝트에 최소한의 설정으로 부드럽게 통합됩니다. 소셜 로그인을 통해 사용자 온보딩을 강화하려는 앱에 이상적입니다.
사용 사례
소셜 로그인 통합
VK를 통한 사용자 온보딩
프로필 데이터 검색
모바일 앱 인증
간소화된 로그인 흐름
크로스 플랫폼 소셜 로그인
주요 기능
VK OAuth2 통합
사용자 프로필 데이터 액세스
Android 및 iOS 지원
pub add로 간편 설정
최소한의 보일러플레이트 코드
보안 토큰 처리
적합한 대상
VK 로그인을 필요로 하는 앱
소셜 인증을 사용하는 프로젝트
러시아어 사용자들을 대상으로 하는 개발자
사용자 프로필이 있는 모바일 앱
빠른 인증 구현을 원하는 스타트업
크로스 플랫폼 로그인을 필요로 하는 Flutter 앱
고려 사항
VK 앱 등록 필요
올바른 리디렉션 URI 구성이 필요합니다
인터넷 연결에 따라 다릅니다
추가 권한이 필요할 수 있습니다
VK 계정 소유자에 한함
VK 이용 약관 준수
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
flutter_login_vk
Flutter Plugin to login via VK.com.
Easily add VK login feature in your application. User profile information included.
Android 5.0 and newer (SDK 21). Minimum compileSdkVersion31.
⚠️ If your project was create with Flutter pre 1.12 you should upgrade it to the Android embedding v2.
See https://flutter.dev/go/android-project-migration
Create an app on VK.com https://vk.com/editapp?act=create
Enter "Title".
Select Standalone app as "Platform".
Click "Connect app".
An application will be created. Now select tab "Settings" and copy "App ID"
(referenced as [APP_ID] in this readme).
App settings for Android
Set Package name for Android - your package name for Android application (attribute package in AndroidManifest.xml).
Set Main activity for Android - your main activity class (with package). By default it would be com.yourcompany.yourapp.MainActivity.
To fill up Signing certificate fingerprint for Android you should create SHA1 fingerprint
as described in the documentation
(without SHA1: prefix). Pay attention: you should remove all colons from the fingerprint string.
Add fingerprints for debug and release certificates. Note: if your application uses Google Play App Signing than you should get certificate SHA-1 fingerprint from Google Play Console.
⚠️ Important! You should add fingerprints for every build variants. E.g. if you have CI/CD which build APK for testing
with it's own certificate (it may be auto generated debug certificate or some another) than you should add it's fingerprint too.
Click "Save".
App settings for iOS
Add your Bundle Identifier - set App Bundle ID for iOS (you can find it in Xcode: Runner - Target Runner - General, section Identity, field Bundle Identifier).
Also set App ID for iOS, it's you SKU (you can find it in App Store Connect: My Apps - {Your application} - App Store - App Information, section "General Information"). Mostly often is't the same as bundle ID.
⚠️ NOTE. Check if you already have CFBundleURLTypes or LSApplicationQueriesSchemes keys in your Info.plist. If you have, you should merge their values, instead of adding a duplicate key.
If you want to use scope=nohttps, which we strongly do not recommend, you should also add NSAppTransportSecurity,
see the documentation.
Upload "Square banner" and "A square banner for catalog" - user can see it.
Setup other settings if you need it.
Than go to "Setting" tab and turn on application:
change "App status" from Application off to Application on and visible to all.
Click "Save".
Usage in application
First, you should create an instance of VKLogin.
Than, before any method call or checking accessToken you should initialize VK SDK:
final vk = VKLogin();
await vk.initSdk();
Now you can use the plugin.
Features:
log in via VK.com;
get access token;
get user profile;
get user email;
check if logged in;
log out.
Sample code:
import'package:flutter_login_vk/flutter_login_vk.dart';
// Create an instance of VKLoginfinal vk = VKLogin();
// Initializeawait vk.initSdk();
// Log infinal res = await vk.logIn(scope: [
VKScope.email,
VKScope.friends,
]);
// Check resultif (res.isValue) {
// There is no error, but we don't know yet// if user logged in or not.// You should check isCanceledfinalVKLoginResult result = res.asValue!.value;
if (result.isCanceled) {
// User cancel log in
} else {
// Logged in// Send access token to server for validation and authfinalVKAccessToken? accessToken = result.accessToken;
if (accessToken != null) {
print('Access token: ${accessToken.token}');
// Get profile datafinal profileRes = await vk.getUserProfile();
final profile = profileRes.asValue?.value;
if (profile != null) {
print('Hello, ${profile.firstName}! You ID: ${profile.userId}');
}
// Get email (since we request email permissions)final email = await vk.getUserEmail();
print('And your email is $email');
} else {
print('Something goes wrong');
}
}
} else {
// Log in failedfinal errorRes = res.asError!;
print('Error while log in: ${errorRes.error}');
}
Initialization notes
When you call initSdk(), plugin try to restore previous session.
If token has been expired - it will be refreshed.
Also, during restoring, log in screen may be shown to user
(only if user was logged in).
In additional, you can pass to initSdk() required scope,
and if current user session doesn't provide it - user will be
logged out.
Also you can specify API version to use, but you shouldn't.