Firebase-ios-sdk: NSInvalidArgumentException, reason: 'data parameter is nil' when parsing FIRUser IDToken

Created on 11 Apr 2018  路  20Comments  路  Source: firebase/firebase-ios-sdk

[READ] Step 1: Are you in the right place?

  • For issues or feature requests related to __the code in this repository__
    file a Github issue.

    • If this is a __feature request__ make sure the issue title starts with "FR:".

  • For general technical questions, post a question on StackOverflow
    with the firebase tag.
  • For general Firebase discussion, use the firebase-talk
    google group.
  • For help troubleshooting your application that does not fall under one
    of the above categories, reach out to the personalized
    Firebase support channel.

[REQUIRED] Step 2: Describe your environment

  • Xcode version: 9.3
  • Firebase SDK version: 4.12.0
  • Firebase Component: Auth
  • Component version: 4.6.0

[REQUIRED] Step 3: Describe the problem

When trying to retrieve a user's firebase id token using .getIdToken(), this call stack is thrown:

    0   CoreFoundation                      0x00000001176b51e6 __exceptionPreprocess + 294
    1   libobjc.A.dylib                     0x00000001162c4031 objc_exception_throw + 48
    2   CoreFoundation                      0x000000011772a975 +[NSException raise:format:] + 197
    3   Foundation                          0x0000000115d05cf0 +[NSJSONSerialization JSONObjectWithData:options:error:] + 67
    4   eulerity-ios dev                    0x000000010dc2cd4c -[FIRUser parseIDToken:error:] + 261
    5   eulerity-ios dev                    0x000000010dc2ca3d __53-[FIRUser getIDTokenResultForcingRefresh:completion:]_block_invoke_2 + 82
    6   eulerity-ios dev                    0x000000010dc2d0c4 __51-[FIRUser internalGetTokenForcingRefresh:callback:]_block_invoke + 183
    7   eulerity-ios dev                    0x000000010dc27a97 __65-[FIRSecureTokenService fetchAccessTokenForcingRefresh:callback:]_block_invoke + 93
    8   eulerity-ios dev                    0x000000010dc2531e __38-[FIRAuthSerialTaskQueue enqueueTask:]_block_invoke + 114
    9   libdispatch.dylib                   0x0000000118b7c807 _dispatch_call_block_and_release + 12
    10  libdispatch.dylib                   0x0000000118b7d848 _dispatch_client_callout + 8
    11  libdispatch.dylib                   0x0000000118b85c41 _dispatch_queue_serial_drain + 1305
    12  libdispatch.dylib                   0x0000000118b86556 _dispatch_queue_invoke + 328
    13  libdispatch.dylib                   0x0000000118b8592d _dispatch_queue_serial_drain + 517
    14  libdispatch.dylib                   0x0000000118b86556 _dispatch_queue_invoke + 328
    15  libdispatch.dylib                   0x0000000118b823a0 _dispatch_queue_override_invoke + 726
    16  libdispatch.dylib                   0x0000000118b893c8 _dispatch_root_queue_drain + 664
    17  libdispatch.dylib                   0x0000000118b890d2 _dispatch_worker_thread3 + 132
    18  libsystem_pthread.dylib             0x00000001190a71ca _pthread_wqthread + 1387
    19  libsystem_pthread.dylib             0x00000001190a6c4d start_wqthread + 13

I did not experience this error prior to updating my pod file from 4.4.4 to 4.6.0.
I am getting the same error when I use the preferred method .getIdTokenForcingRefresh(Bool).

Steps to reproduce:

What happened? How can we make the problem occur?
This could be a description, log/console output, etc.

Using FirebaseAuth pod 4.6.0, call the instance method getIdToken() on the current firebase user.

auth bug

Most helpful comment

The fix has been pushed to master from #1076 and we're working to get a 4.12.1 release deployed.

See the instructions here and use the 'master' tag if you'd like to try out the fix earlier.

All 20 comments

I was just coming here to report this. I'm seeing it, along with 2 others - https://stackoverflow.com/questions/49771555/firebase-auth-error-data-parameter-is-nil-calling-getidtokenforcingrefresh

Easy repro (will crash):

        let currentUser = Auth.auth().currentUser
        currentUser?.getIDTokenForcingRefresh(true) { idToken, error in
            if let error = error {
                // Handle error
                return;
            }

            // Send token to your backend via HTTPS
            // ...
        }

Also fails with all other permutations of getIDTokenxxxxxx()

It seems like Firebase found a workaround. If you run pod install a few library are downgraded:

Installing Firebase 4.5.0 (was 4.12.0)
Installing FirebaseAnalytics 4.0.4 (was 4.1.0)
Installing FirebaseAuth 4.3.1 (was 4.6.0)
Installing FirebaseCore 4.0.10 (was 4.0.19)
Installing FirebaseMessaging 2.0.6 (was 2.2.0)

After that it's working again.

I'm seeing the same issue but was able to fix it by

  • first logout on the prod (store) build
  • install & login on the debug build

Edit:

This does not fix the problem, login with google or email still broken, fb works fine.
switch back to 4.11 and everything works.

Gosh. Our team spent 5 h on this task, thanks for hint to roll back to 4.11.0

I'm able to successfully use the below versions in my project. I had a bit of trouble pegging all the specific versions of the Firebase libraries in my Podfile and had to use the .lock file instead. If you run pod install, Cocoapods will resolve dependencies for whatever is not in your Podfile.lock. As per Cocoapods docs,

For pods listed in the Podfile.lock, it downloads the explicit version listed in the Podfile.lock without trying to check if a newer version is available

Since the issue is with the newer version, this can be fixed by downgrading. My suggestion is to try replacing references to Firebase in your Podfile.lock with the following, until this issue is resolved by the Firebase SDK team:

PODS:
  - Firebase/Auth (4.8.2):
    - Firebase/Core
    - FirebaseAuth (= 4.4.2)
  - Firebase/Core (4.8.2):
    - FirebaseAnalytics (= 4.0.9)
    - FirebaseCore (= 4.0.14)
  - Firebase/Database (4.8.2):
    - Firebase/Core
    - FirebaseDatabase (= 4.1.4)
  - Firebase/DynamicLinks (4.8.2):
    - Firebase/Core
    - FirebaseDynamicLinks (= 2.3.2)
  - Firebase/Firestore (4.8.2):
    - Firebase/Core
    - FirebaseFirestore (= 0.10.0)
  - Firebase/Messaging (4.8.2):
    - Firebase/Core
    - FirebaseMessaging (= 2.0.8)
  - Firebase/Performance (4.8.2):
    - Firebase/Core
    - FirebasePerformance (= 1.1.1)
  - Firebase/Storage (4.8.2):
    - Firebase/Core
    - FirebaseStorage (= 2.1.2)
  - FirebaseAnalytics (4.0.9):
    - FirebaseCore (~> 4.0)
    - FirebaseInstanceID (~> 2.0)
    - "GoogleToolboxForMac/NSData+zlib (~> 2.1)"
    - nanopb (~> 0.3)
  - FirebaseAuth (4.4.2):
    - FirebaseAnalytics (~> 4.0)
    - "GoogleToolboxForMac/NSDictionary+URLArguments (~> 2.1)"
    - GTMSessionFetcher/Core (~> 1.1)
  - FirebaseCore (4.0.14):
    - "GoogleToolboxForMac/NSData+zlib (~> 2.1)"
  - FirebaseDatabase (4.1.4):
    - FirebaseAnalytics (~> 4.0)
    - FirebaseCore (~> 4.0)
    - leveldb-library (~> 1.18)
  - FirebaseDynamicLinks (2.3.2):
    - FirebaseAnalytics (~> 4.0)
  - FirebaseFirestore (0.10.0):
    - FirebaseAnalytics (~> 4.0)
    - FirebaseCore (~> 4.0)
    - gRPC-ProtoRPC (~> 1.0)
    - leveldb-library (~> 1.18)
    - Protobuf (~> 3.1)
  - FirebaseInstanceID (2.0.8):
    - FirebaseCore (~> 4.0)
  - FirebaseMessaging (2.0.8):
    - FirebaseAnalytics (~> 4.0)
    - FirebaseCore (~> 4.0)
    - FirebaseInstanceID (~> 2.0)
    - GoogleToolboxForMac/Logger (~> 2.1)
    - Protobuf (~> 3.1)
  - FirebasePerformance (1.1.1):
    - FirebaseAnalytics (~> 4.0)
    - FirebaseInstanceID (~> 2.0)
    - FirebaseSwizzlingUtilities (~> 1.0)
    - GoogleToolboxForMac/Logger (~> 2.1)
    - "GoogleToolboxForMac/NSData+zlib (~> 2.1)"
    - GTMSessionFetcher/Core (~> 1.1)
    - Protobuf (~> 3.1)
  - FirebaseStorage (2.1.2):
    - FirebaseAnalytics (~> 4.0)
    - FirebaseCore (~> 4.0)
    - GTMSessionFetcher/Core (~> 1.1)
  - FirebaseSwizzlingUtilities (1.0.0)
  - FirebaseUI (4.5.1):
    - FirebaseUI/All (= 4.5.1)
  - FirebaseUI/All (4.5.1):
    - FirebaseUI/Auth
    - FirebaseUI/Database
    - FirebaseUI/Facebook
    - FirebaseUI/Firestore
    - FirebaseUI/Google
    - FirebaseUI/Phone
    - FirebaseUI/Storage
    - FirebaseUI/Twitter
  - FirebaseUI/Auth (4.5.1):
    - Firebase/Auth (~> 4.2)
  - FirebaseUI/Database (4.5.1):
    - Firebase/Database (~> 4.0)
  - FirebaseUI/Facebook (4.5.1):
    - FBSDKLoginKit (~> 4.0)
    - FirebaseUI/Auth
  - FirebaseUI/Firestore (4.5.1):
    - Firebase/Firestore
  - FirebaseUI/Google (4.5.1):
    - FirebaseUI/Auth
    - GoogleSignIn (~> 4.0)
  - FirebaseUI/Phone (4.5.1):
    - FirebaseUI/Auth
  - FirebaseUI/Storage (4.5.1):
    - Firebase/Storage (~> 4.0)
    - SDWebImage (~> 4.0)
  - FirebaseUI/Twitter (4.5.1):
    - FirebaseUI/Auth
    - TwitterKit (~> 3.0)

We are also experiencing the same issue.

@bryanbartow try rolling back in the interim. Worked for us and we're able to keep moving forward.

@JaredHalpern Yep. Just rolled back to 4.11.0 and everything is back to normal. Thanks.

We're working on a fix. In the meantime, you can workaround by rolling Firebase back to 4.11.0 with FirebaseAuth 4.5.0.

The fix has been pushed to master from #1076 and we're working to get a 4.12.1 release deployed.

See the instructions here and use the 'master' tag if you'd like to try out the fix earlier.

Thank you @paulb777 & @morganchen12 !

4.13.0 is now published to CocoaPods with fix.

Still having this issue on 4.13. Rolling back to 4.11 for now. This really happened at an inopportune moment... That should teach me to update my pods right before release :/

Downgrading the library gives me the following linker error:

Undefined symbols for architecture arm64:
"_kFIRLoggerSwizzler", referenced from:
___63+[FIRSwizzler swizzleClass:selector:isClassSelector:withBlock:]_block_invoke in FirebaseMethodSwizzler(FIRSwizzler_360b26e2244d68994ab8f6788d06111b.o)
ld: symbol(s) not found for architecture arm64

EDIT:
Had to revert to an older podfile.lock that seemed to work. Must have been some weird dependency stuff going on.

If anyone is having this issue on 4.13.0, please open a new issue and share your backtrace, Podfile, and Podfile.lock

@Nailer Same here. Looks like Google sign in works, but now Facebook sign in is broken.

@bryanbartow Yeah! That's exactly the login type I was struggling with yesterday. Holy adrenaline-fueled batman what a ride it was too. It was midnight, and I needed to get that stuff sent to apple for review. 0/10 would not recommend.

@bryanbartow Are you getting an error/exception when signing into Facebook? Or when refreshing/force refreshing the token? Is it the same error at the beginning of this thread?

@protocol86 Crashing on [FIRUser parseIDToken:error:]. It's the same error I was getting earlier.

@bryanbartow please post a new issue with your stack trace and Firebase versions.

Was this page helpful?
0 / 5 - 0 ratings