question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: Twitter auth provider cannot transition from native auth to Firebase JS SDK auth

See original GitHub issue

Plugin(s): @capacitor-firebase/authentication@0.3.0

Platform(s): iOS

Current behavior: Twitter Auth Provider cannot transition from native auth to Firebase JS SDK auth. The FirebaseAuthentication.signInWithTwitter() method returns no result.credential.accessToken nor result.credential.secret (both undefined). Thus I’m unable to get the OAuthCredential using const nativeCredential = TwitterAuthProvider.credential(result.credential?.accessToken, result.credential?.secret) in order to perform the authentication on the web layer with signInWithCredential(auth, nativeCredential).

Expected behavior: Twitter auth provider returns credential.accessToken and credential.secret (like it does on Android) and we can use those to perform the authentication on the web layer with signInWithCredential(auth, nativeCredential).

Steps to reproduce: I followed the steps mentioned in the How to use this plugin with the Firebase JavaScript SDK guide.

Related code: But as the Twitter example is missing I used the following (based on the other examples)

const signInWithTwitter = async () => {
  // 1. Create credentials on the native layer
  const result = await FirebaseAuthentication.signInWithTwitter();
  // 2. Sign in on the web layer using the access token
  const credential = TwitterAuthProvider.credential(result.credential?.accessToken, result.credential?.secret);
  const auth = getAuth();
  await signInWithCredential(auth, credential);
};

Other information: My project is working fine on Android and the web. On iOS I got these errors on the Safari DevTools console:

  • FirebaseError: Firebase: Error (auth/argument-error).
  • null is not an object (evaluating ‘credential._getIdTokenResponse’)

This is the way I’m initializing the @angular/fire library in my NgModule according to this comment and this comment:

...

provideFirebaseApp(() => {
    const app = initializeApp(environment.firebase);

    if (Capacitor.isNativePlatform()) {
      initializeAuth(app, {
        persistence: indexedDBLocalPersistence
      });
    }
    return app;
  }),
  provideAuth(() => getAuth())

...

I also tried this alternate init with no luck. I don’t believe this is the cause anyway:

provideFirebaseApp(() => initializeApp(environment.firebase)),
provideAuth(() => {
  if (Capacitor.isNativePlatform()) {
    return initializeAuth(getApp(), {
      persistence: indexedDBLocalPersistence
    });
  } else {
    return getAuth();
  }
}),

Capacitor doctor:

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 3.5.1
  @capacitor/core: 3.5.1
  @capacitor/android: 3.5.1
  @capacitor/ios: 3.5.1

Installed Dependencies:

  @capacitor/cli: 3.5.1
  @capacitor/ios: 3.5.1
  @capacitor/android: 3.5.1
  @capacitor/core: 3.5.1

[success] iOS looking great! 👌
[error] Missing <manifest package=""> attribute in app/src/main

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
robingenzcommented, Jun 11, 2022

Okay, i found the issue and fixed it. You can give it a try if you want:

npm i @capacitor-firebase/authentication@0.3.0-dev.2c2ae36.1654944437

I will release this fix in a few days.

Thank you for the report @agustinhaller !

1reaction
robingenzcommented, Jun 3, 2022

@agustinhaller Unfortunately I could not gather more information. I created an issue in the firebase-ios-sdk repo: https://github.com/firebase/firebase-ios-sdk/issues/9878

Read more comments on GitHub >

github_iconTop Results From Across the Web

bug: Twitter auth provider cannot transition from native auth to ...
Current behavior: Twitter Auth Provider cannot transition from native auth to Firebase JS SDK auth. The FirebaseAuthentication.signInWithTwitter ...
Read more >
Authenticate Using Twitter in JavaScript | Firebase - Google
You can let your users authenticate with Firebase using their Twitter accounts by integrating Twitter authentication into your app.
Read more >
ios - Firebase Auth - get provider ID - Stack Overflow
Swift 4 solution: if let providerData = Auth.auth().currentUser?.providerData { for userInfo in providerData { switch userInfo.
Read more >
firebase_auth | Flutter Package - Pub.dev
Flutter plugin for Firebase Auth, enabling Android and iOS authentication using passwords, phone numbers and identity providers like Google, Facebook and ...
Read more >
Build a Role-based API with Firebase Authentication - Toptal
Create a role-based authorization API with a fine-grained permissions model. Allow only specific users access to certain resources. All with Node.js and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found