【问题标题】:Flutter Twitter Auth Error, Missing InitialStateFlutter Twitter Auth 错误,缺少 InitialState
【发布时间】:2021-04-15 20:08:57
【问题描述】:

最近我开始使用 Twitter 集成。

回调正常工作。

但是当我按下 Authorize App 时,我一直收到此错误。

由于缺少初始状态,无法处理请求。如果浏览器会话存储不可访问或意外清除,则可能会发生这种情况

这是我调用 twitter_login 的函数。

@override
  Future<FbUser> signInWithTwitter(
      Function(AuthException) exceptionCallback) async {
    var me;
    final twitterLogin = TwitterLogin(
        apiKey: 'xxxxxxxxx',
        apiSecretKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
        redirectURI: 'https://volado-app.firebaseapp.com/__/auth/handler');
    // Trigger the sign-in flow
    try {
      final authResult = await twitterLogin.login();
      switch (authResult.status) {
        case TwitterLoginStatus.loggedIn:
          final twitterAuthProvider = TwitterAuthProvider.credential(
              accessToken: authResult.authToken,
              secret: authResult.authTokenSecret);
          final userCredential = await FirebaseAuth.instance
              .signInWithCredential(twitterAuthProvider);
          return userFromFirebase(userCredential.user);
          break;
        case TwitterLoginStatus.cancelledByUser:
          exceptionCallback(AuthException(
              code: authResult.status.toString(),
              message: 'login canceled by user'));
          break;
        case TwitterLoginStatus.error:
          print(authResult.errorMessage);
          exceptionCallback(AuthException(
              code: authResult.status.toString(), message: 'Error login'));
          break;
      }
    } catch (e) {
      exceptionCallback(
          AuthException(code: e.errorCode, message: 'Unknown error'));
    }
    return me;
    // Get the Logged In session
  }

在我的 AndroidManifest 我的活动标签中有这个

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <!-- Accepts URIs that begin with "example://gizmos” -->
            <!-- Registered Callback URLs in TwitterApp -->
            <data android:host="volado-app.firebaseapp.com" /> <!-- host is option -->
        </intent-filter>

我搜索,唯一几乎接近的是:

Angular FirebaseUI Auth via Twitter, GitHub, Microsoft Not Working

但问题出在 Angular 上,我没有看到任何拼写错误的问题 :(

【问题讨论】:

    标签: firebase flutter dart


    【解决方案1】:

    在试图找出问题几个小时后,我发现问题出在 AndroidManifest.xml

    基本上在意图过滤器上,该方案丢失了,我需要从主机和函数调用中删除 https。之后它工作:)

                <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="https"
                            android:host="volado-app.firebaseapp.com" />
                </intent-filter>
    

    【讨论】:

      猜你喜欢
      • 2021-12-30
      • 2010-11-30
      • 1970-01-01
      • 2017-12-15
      • 2014-12-08
      • 2019-11-01
      • 2012-04-21
      • 2012-02-17
      • 2012-05-09
      相关资源
      最近更新 更多