-
(구)Twitter (현)X 로그인 구현 - Flutterflutter 2024. 8. 9. 11:50반응형
오늘은 플러터를 이용한 트위터 로그인 기능을 구현해 보겠습니다.
https://firebase.flutter.dev/docs/auth/social/#twitter
공식 사이트
1. 트위터 개발자 계정 만들기
2. 개발자 포털
https://developer.x.com/en/docs/twitter-api/getting-started/getting-access-to-the-twitter-api
가입 선택
Developer agreement & policy 정보 입력 (영어로) - 250자 이상이어야함
제출후 아래와 같은 페이지 이동
스크롤을 좀 내리면 하단에 Set UP 선택
필요한 정보 입력 후 save
Ouath 2.0 클라이언트 ID와 비밀번호 생성
이제 Pub.dev 에 접근
https://pub.dev/packages/twitter_login
패키지 추가
이후 먼저 ios info.plist
안드로이드 manifest
<meta-data android:name="flutterEmbedding" android:value="2" />
주의 할점:
1. 아래의 코드 제거
android:host="gizmos"
2. activity 를 새로 만들지 말고 기존에 있는 activity 에 intent-filter 추가해주기
<intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE"/> <data android:scheme="앱이름" /> <!-- host is option --> </intent-filter>
셋팅완료
이제 코드 를 입력해보자
OutlinedButton(
onPressed: () async {
final twitterLogin = TwitterLogin(
apiKey: '트위터 Developer Potal의 api key 입력',
apiSecretKey: '트위터 Developer Potal의 api secret key 입력',
redirectURI: '콜백 URL',
);
final authResult = await twitterLogin.login();
switch (authResult.status) {
case TwitterLoginStatus.loggedIn:
// success
break;
case TwitterLoginStatus.cancelledByUser:
// cancel
break;
case TwitterLoginStatus.error:
// error
break;
}
},만약 키를 모른다면 재 생성 Regenerate 선택 하면 재생성후 조회 가능
반응형'flutter' 카테고리의 다른 글
이전 페이지가 백그라운드에서 계속 빌드되지 않도록 하기 (0) 2024.10.17 구글 플레이스토어 콘솔 recaptcha 관련 이슈 (1) 2024.10.15 GetX 추가 정리 - 2023.12.15 (0) 2023.12.15 Kakao API - Flutter (0) 2023.06.07 receive_sharing_intent 환경 셋팅 관련 IOS 오류 (0) 2023.05.11