Flutter - Firebase - Twitter 身份验证问题

问题描述 投票:0回答:1

我正在尝试使用 flutter 和 firebase 验证 twitter。但在 Twitter 上授权后无法登陆我的申请页面。

图片: 001 001:启动应用程序登录按钮将重定向到 Twitter 页面(图片 002)

002从 Twitter 页面,当我单击“授权应用程序”时,它会切换到图像 003“social_demo”,这是我的 androidmenifest.xml 中的应用程序标签。

003然后我点击返回,它重定向到 Twitter 页面,并显示错误消息 Image 004。

004最后,如果我关闭它或单击返回,我会在应用程序“TwitterLoginStatus.cancelledByUser”中收到调试消息。

步骤是:

从应用程序重定向到 Twitter

  Future signInWithTwitter() async {
    final twitterLogin = TwitterLogin(
      apiKey: "xxxxxxxxxx",
      apiSecretKey: "xxxxxxxxx",
      redirectURI: 'flutter-twitter-auth://',
    );

    await twitterLogin.login().then((value) {
      debugPrint(value.status.toString());
    });
message => TwitterLoginStatus.cancelledByUser

Androidmenifest.xml

   <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="flutter-twitter-auth"/>

           </intent-filter>

pubspec.yaml

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.4
  firebase_auth: ^3.2.0
  google_sign_in: ^5.2.1
  google_fonts: ^2.1.0
  flutter_facebook_auth: ^3.5.6
  twitter_login: ^4.0.1

寻找解决方案...如果有人遇到这个问题。

推特:Twitter

firebase flutter authentication twitter
1个回答
0
投票

我面临着同样的问题,(浏览

twitter_login: ^4.0.1
文档)找到了罪魁祸首。

<data android:scheme="flutter-twitter-auth"/>

将上面的内容替换为,

<data android:scheme="your_app_name"/>

也替换下面的代码片段

final twitterLogin = TwitterLogin(
      apiKey: "xxxxxxxxxx",
      apiSecretKey: "xxxxxxxxx",
      redirectURI: 'flutter-twitter-auth://',
    );

final twitterLogin = TwitterLogin(
      apiKey: "xxxxxxxxxx",
      apiSecretKey: "xxxxxxxxx",
      redirectURI: 'your_app_name://',
    );

最后 Twitter 开发者帐户中的回调 URL 应该是,

your_app_name://
© www.soinside.com 2019 - 2024. All rights reserved.