【问题标题】:Flutter - Firebase - Twitter Authentication issueFlutter - Firebase - Twitter 身份验证问题
【发布时间】:2021-12-02 07:14:34
【问题描述】:

我正在尝试使用 Flutter 和 Firebase 对 twitter 进行身份验证。但在推特上授权后无法返回我的应用程序页面。

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

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

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

004finally 如果我关闭它或单击返回,我会在应用程序“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】:

    我遇到了同样的问题,(通过twitter_login: ^4.0.1 文档)找到了罪魁祸首。

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

    将上面的替换为,

    <data android:scheme="your_app_name"/>
    

    也替换下面的sn-p

    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://
    

    【讨论】:

      猜你喜欢
      • 2021-12-09
      • 2021-04-21
      • 2020-11-27
      • 2020-05-28
      • 2020-01-23
      • 2021-03-22
      • 1970-01-01
      • 2011-04-25
      相关资源
      最近更新 更多