Flutter Twitter Auth Error, Missing InitialState

2,036

After some hours trying to figure out the problem, i found that the issue was on the AndroidManifest.xml

Basically on the intent-filter, the scheme was missing, and i need to remove the https from the host and the function call. After that it work :)

            <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>
Share:
2,036
Luis Cardoza Bird
Author by

Luis Cardoza Bird

http://crdzbird-portfolio.herokuapp.com/

Updated on December 26, 2022

Comments

  • Luis Cardoza Bird
    Luis Cardoza Bird 5 minutes

    Recently i started with a Twitter Integration.

    The callback is working as it should.

    but when i press the Authorize App i keep receiving this error.

    unable to process request due to missing initial state. this may happen if browser sessionstorage is inaccesible or accidentally cleared

    Error_Login

    This is the function where i call the 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
      }
    

    on my AndroidManifest i have this inside my activity tag

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

    i search and the only thing almost close was this:

    Angular FirebaseUI Auth via Twitter, GitHub, Microsoft Not Working

    But the issue was for angular, and the url i don't see any problem of misspelling :(