Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ErrorCode 17999 #12808

Closed
jostster opened this issue Apr 17, 2024 · 32 comments
Closed

ErrorCode 17999 #12808

jostster opened this issue Apr 17, 2024 · 32 comments

Comments

@jostster
Copy link
Contributor

jostster commented Apr 17, 2024

Description

iOS users randomly receive ErrorCode 17999

 Error Domain=FIRAuthErrorDomain Code=17999 \"An internal error has occurred, print and inspect the error details for more information.\" UserInfo={FIRAuthErrorUserInfoNameKey=ERROR_INTERNAL_ERROR, NSLocalizedDescription=An internal error has occurred, print and inspect the error details for more information., NSUnderlyingError=0x302e96790 {Error Domain=FIRAuthInternalErrorDomain Code=3 \"(null)\" UserInfo={NSUnderlyingError=0x302c5a8b0 {Error Domain=com.google.HTTPStatus Code=401 \"(null)\" UserInfo={data={length = 284, bytes = 0x7b0a20 ... }, data_content_type=application/json; charset=UTF-8}}, FIRAuthErrorUserInfoDeserializedResponseKey={\n    code = 401;\n    errors =     (\n                {\n            domain = global;\n            message = \"Firebase App Check token is invalid.\";\n            reason = unauthorized;\n        }\n    );\n    message = \"Firebase App Check token is invalid.\";\n    status = UNAUTHENTICATED;\n}}}}"

Could be a regression of #11926 which was fixed. I am unable to replicate this locally but many users are saying they are encountering this with some saying a re-install isn't resolving it.

I feel that the AppCheck token isn't being re-generated when a 17999 error is received.

Reproducing the issue

Unable to repro locally, but users just attempt to login with username / password using signInWithEmailPassword with AppCheck enabled.

Firebase SDK Version

10.23.1

Xcode Version

15.3

Installation Method

Swift Package Manager

Firebase Product(s)

App Check, Authentication, Crashlytics, DynamicLinks

Targeted Platforms

iOS

Relevant Log Output

No response

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet
{
  "pins" : [
    {
      "identity" : "abseil-cpp-binary",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/abseil-cpp-binary.git",
      "state" : {
        "revision" : "7ce7be095bc3ed3c98b009532fe2d7698c132614",
        "version" : "1.2024011601.0"
      }
    },
    {
      "identity" : "alamofire",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/Alamofire/Alamofire.git",
      "state" : {
        "revision" : "bc268c28fb170f494de9e9927c371b8342979ece",
        "version" : "5.7.1"
      }
    },
    {
      "identity" : "alamofireimage",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/Alamofire/AlamofireImage.git",
      "state" : {
        "revision" : "98cbb00ce0ec5fc8e52a5b50a6bfc08d3e5aee10",
        "version" : "4.2.0"
      }
    },
    {
      "identity" : "amplitude-ios",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/amplitude/Amplitude-iOS",
      "state" : {
        "revision" : "94160a550835e6f0a1df9fa76ab3902ac4648a9c",
        "version" : "8.17.1"
      }
    },
    {
      "identity" : "analytics-connector-ios",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/amplitude/analytics-connector-ios.git",
      "state" : {
        "revision" : "d2f3ec4b022211a67d5d4509135d84359f7f8b8d",
        "version" : "1.0.2"
      }
    },
    {
      "identity" : "apollo-ios",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/apollographql/apollo-ios.git",
      "state" : {
        "revision" : "97ad4f5b41f003f4f283c5f3386fb773af17aa67",
        "version" : "1.3.2"
      }
    },
    {
      "identity" : "app-check",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/app-check.git",
      "state" : {
        "revision" : "3e464dad87dad2d29bb29a97836789bf0f8f67d2",
        "version" : "10.18.1"
      }
    },
    {
      "identity" : "appsflyerframework",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/AppsFlyerSDK/AppsFlyerFramework",
      "state" : {
        "revision" : "d798f38fdc006621f5720579fdcba292c522a660",
        "version" : "6.12.1"
      }
    },
    {
      "identity" : "asn1swift",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/tikhop/ASN1Swift",
      "state" : {
        "revision" : "b53bee03a942623db25afc5bfb80227b2cb3b425",
        "version" : "1.2.4"
      }
    },
    {
      "identity" : "aws-signer-v4",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/adam-fowler/aws-signer-v4.git",
      "state" : {
        "revision" : "2e205327f842f808340e7e40eee3f9dec7e1f649",
        "version" : "2.1.1"
      }
    },
    {
      "identity" : "braze-swift-sdk",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/braze-inc/braze-swift-sdk",
      "state" : {
        "revision" : "e42292d5b782eabb9a8a40d839f04df6a62bebc7",
        "version" : "8.2.1"
      }
    },
    {
      "identity" : "chargebee-ios",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/tommyboytech/chargebee-ios",
      "state" : {
        "revision" : "479e2759a86b28a5653829e1ae97375dfa365c99"
      }
    },
    {
      "identity" : "cocoalumberjack",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/CocoaLumberjack/CocoaLumberjack.git",
      "state" : {
        "revision" : "af4973721172dd7850a42a58a9ffcec0ec82e5a9",
        "version" : "3.8.4"
      }
    },
    {
      "identity" : "confettiswiftui",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/simibac/ConfettiSwiftUI.git",
      "state" : {
        "revision" : "f45961f97bbae6fff6e2e64546fea0189425ad92",
        "version" : "1.1.0"
      }
    },
    {
      "identity" : "experiment-ios-client",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/amplitude/experiment-ios-client",
      "state" : {
        "revision" : "e2909462c1f4be3df5b3d27ca535f6500ef5f101",
        "version" : "1.11.0"
      }
    },
    {
      "identity" : "facebook-ios-sdk",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/facebook/facebook-ios-sdk",
      "state" : {
        "revision" : "c19607d535864533523d1f437c84035e5fb101cf",
        "version" : "14.1.0"
      }
    },
    {
      "identity" : "factory",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/hmlongco/Factory",
      "state" : {
        "revision" : "39ff6a675cd0272d833d184d35add0f8fddd63de",
        "version" : "1.3.7"
      }
    },
    {
      "identity" : "firebase-ios-sdk",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/firebase/firebase-ios-sdk.git",
      "state" : {
        "revision" : "888f0b6026e2441a69e3ee2ad5293c7a92031e62",
        "version" : "10.23.1"
      }
    },
    {
      "identity" : "googleappmeasurement",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/GoogleAppMeasurement.git",
      "state" : {
        "revision" : "c7a5917ebe48d69f421aadf154ef3969c8b7f12d",
        "version" : "10.23.1"
      }
    },
    {
      "identity" : "googledatatransport",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/GoogleDataTransport.git",
      "state" : {
        "revision" : "a637d318ae7ae246b02d7305121275bc75ed5565",
        "version" : "9.4.0"
      }
    },
    {
      "identity" : "googleutilities",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/GoogleUtilities.git",
      "state" : {
        "revision" : "26c898aed8bed13b8a63057ee26500abbbcb8d55",
        "version" : "7.13.1"
      }
    },
    {
      "identity" : "grpc-binary",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/grpc-binary.git",
      "state" : {
        "revision" : "67043f6389d0e28b38fa02d1c6952afeb04d807f",
        "version" : "1.62.1"
      }
    },
    {
      "identity" : "gtm-session-fetcher",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/gtm-session-fetcher.git",
      "state" : {
        "revision" : "d415594121c9e8a4f9d79cecee0965cf35e74dbd",
        "version" : "3.1.1"
      }
    },
    {
      "identity" : "gzipswift",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/1024jp/GzipSwift",
      "state" : {
        "revision" : "731037f6cc2be2ec01562f6597c1d0aa3fe6fd05",
        "version" : "6.0.1"
      }
    },
    {
      "identity" : "inflectorkit",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/mattt/InflectorKit",
      "state" : {
        "revision" : "d8cbcc04972690aaa5fc760a2b9ddb3e9f0decd7",
        "version" : "1.0.0"
      }
    },
    {
      "identity" : "interop-ios-for-google-sdks",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/interop-ios-for-google-sdks.git",
      "state" : {
        "revision" : "2d12673670417654f08f5f90fdd62926dc3a2648",
        "version" : "100.0.0"
      }
    },
    {
      "identity" : "ios-analytics-debugger-spm",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/avohq/ios-analytics-debugger-spm",
      "state" : {
        "revision" : "b866a2ac3bb7540d17478e8cdca55fbef94abaf8",
        "version" : "1.3.0"
      }
    },
    {
      "identity" : "ios-places-sdk",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/googlemaps/ios-places-sdk",
      "state" : {
        "revision" : "2a9c7305a0e5f83b9acdccfc74eb545ffeb476c3",
        "version" : "8.5.0"
      }
    },
    {
      "identity" : "leveldb",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/firebase/leveldb.git",
      "state" : {
        "revision" : "0706abcc6b0bd9cedfbb015ba840e4a780b5159b",
        "version" : "1.22.2"
      }
    },
    {
      "identity" : "lottie-spm",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/airbnb/lottie-spm.git",
      "state" : {
        "revision" : "60ea4f82fba8b4cb21a75665a889e86ed4d81c6e",
        "version" : "4.2.0"
      }
    },
    {
      "identity" : "markdownkit",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/bmoliveira/MarkdownKit.git",
      "state" : {
        "revision" : "5056f3305d3499f44d8815530d560b87082e0cf5",
        "version" : "1.7.1"
      }
    },
    {
      "identity" : "nanopb",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/firebase/nanopb.git",
      "state" : {
        "revision" : "819d0a2173aff699fb8c364b6fb906f7cdb1a692",
        "version" : "2.30909.0"
      }
    },
    {
      "identity" : "phonenumberkit",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/marmelroy/PhoneNumberKit.git",
      "state" : {
        "revision" : "9bc965a326df8d5115f0b7bb77f09c542b8ec417",
        "version" : "3.6.6"
      }
    },
    {
      "identity" : "promises",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/google/promises.git",
      "state" : {
        "revision" : "e70e889c0196c76d22759eb50d6a0270ca9f1d9e",
        "version" : "2.3.1"
      }
    },
    {
      "identity" : "rollbar-apple",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/rollbar/rollbar-apple",
      "state" : {
        "revision" : "8f22deced5e5c58cfcf923395a9ac8496b3bc371",
        "version" : "3.2.1"
      }
    },
    {
      "identity" : "sdwebimage",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/SDWebImage/SDWebImage.git",
      "state" : {
        "revision" : "f6afa0132961d593f07970d84e2d8b588c29ea04",
        "version" : "5.19.1"
      }
    },
    {
      "identity" : "sqlite.swift",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/stephencelis/SQLite.swift.git",
      "state" : {
        "revision" : "7a2e3cd27de56f6d396e84f63beefd0267b55ccb",
        "version" : "0.14.1"
      }
    },
    {
      "identity" : "stripe-ios",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/stripe/stripe-ios",
      "state" : {
        "revision" : "e242f59ce90914e93c8308e0c3ceba7368575b77",
        "version" : "22.8.4"
      }
    },
    {
      "identity" : "swift-argument-parser",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/apple/swift-argument-parser.git",
      "state" : {
        "revision" : "fee6933f37fde9a5e12a1e4aeaa93fe60116ff2a",
        "version" : "1.2.2"
      }
    },
    {
      "identity" : "swift-atomics",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/apple/swift-atomics.git",
      "state" : {
        "revision" : "cd142fd2f64be2100422d658e7411e39489da985",
        "version" : "1.2.0"
      }
    },
    {
      "identity" : "swift-collections",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/apple/swift-collections",
      "state" : {
        "revision" : "937e904258d22af6e447a0b72c0bc67583ef64a2",
        "version" : "1.0.4"
      }
    },
    {
      "identity" : "swift-log",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/apple/swift-log.git",
      "state" : {
        "revision" : "32e8d724467f8fe623624570367e3d50c5638e46",
        "version" : "1.5.2"
      }
    },
    {
      "identity" : "swift-nio",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/apple/swift-nio",
      "state" : {
        "revision" : "635b2589494c97e48c62514bc8b37ced762e0a62",
        "version" : "2.63.0"
      }
    },
    {
      "identity" : "swift-protobuf",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/apple/swift-protobuf.git",
      "state" : {
        "revision" : "f25867a208f459d3c5a06935dceb9083b11cd539",
        "version" : "1.22.0"
      }
    },
    {
      "identity" : "swift-system",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/apple/swift-system.git",
      "state" : {
        "revision" : "025bcb1165deab2e20d4eaba79967ce73013f496",
        "version" : "1.2.1"
      }
    },
    {
      "identity" : "swiftui-tooltip",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/quassum/SwiftUI-Tooltip.git",
      "state" : {
        "revision" : "3bef9a21e2bcf1d0f078ddf6731c3c8996f32c3e",
        "version" : "1.4.0"
      }
    },
    {
      "identity" : "swiftygif",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/kirualex/SwiftyGif.git",
      "state" : {
        "revision" : "d6d26061d6553a493781ad3df4a8e275c43fc373",
        "version" : "5.4.4"
      }
    },
    {
      "identity" : "tpinappreceipt",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/tikhop/TPInAppReceipt.git",
      "state" : {
        "revision" : "5b830d6ce6c34bb4bb976917576ab560e7945037",
        "version" : "3.3.4"
      }
    },
    {
      "identity" : "youtube-ios-player-helper",
      "kind" : "remoteSourceControl",
      "location" : "https://github.com/youtube/youtube-ios-player-helper.git",
      "state" : {
        "revision" : "f57129cd4380ec0a74dd3a59da3270a1d653d59b",
        "version" : "1.0.4"
      }
    }
  ],
  "version" : 2
}

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet
Replace this line with the contents of your Podfile.lock!
@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@ncooke3
Copy link
Member

ncooke3 commented Apr 19, 2024

Hi @jostster, which App Check provider(s) are being used in the project?

@jostster
Copy link
Contributor Author

Hi @jostster, which App Check provider(s) are being used in the project?

We are using AppAttestProvider(app: app)

@jostster
Copy link
Contributor Author

jostster commented May 1, 2024

Looks like more users are seeing this according to our support team. Users have stated they haven't changed devices but maybe they have restored from backup or for some reason the system is holding on to an old token?

@ncooke3 ncooke3 self-assigned this May 1, 2024
@ncooke3
Copy link
Member

ncooke3 commented May 9, 2024

Users have stated they haven't changed devices but maybe they have restored from backup or for some reason the system is holding on to an old token?

In the case where the backup is creating the invalid state, the proposed fix for #12629 may address this.

@jostster
Copy link
Contributor Author

jostster commented May 9, 2024

Users have stated they haven't changed devices but maybe they have restored from backup or for some reason the system is holding on to an old token?

In the case where the backup is creating the invalid state, the proposed fix for #12629 may address this.

That is a possibility but I didn't see anything from that issue about 17999 error code. We have also asked users with this issue to delete and reinstall the application which they say isn't resolving their issue. I have added back code into our next release that will reset the attest key when a 17999 occurs. We will see if that resolves the issue.

@ncooke3
Copy link
Member

ncooke3 commented May 10, 2024

@jostster, from the reports you've seen, does this seem like an issue that won't go away once it starts happening?

@jostster
Copy link
Contributor Author

@ncooke3 it seems hit or miss. Some are saying that reinstalling the app does not resolve the issue while others that specifically stated, they bought a new phone and restored from cloud said that deleting and reinstalling did fix the issue.

@ncooke3
Copy link
Member

ncooke3 commented May 10, 2024

Got it. Thanks, @jostster. I'll release the fix for #12629 early next week and we can then see if it addresses this issue. I have a feeling they are somewhat related.

@ncooke3
Copy link
Member

ncooke3 commented May 13, 2024

Hi @jostster, I just released an update for a core dependency of Firebase App Check. See #12629 (comment)

@ncooke3
Copy link
Member

ncooke3 commented May 29, 2024

Hi @jostster, are you still facing this issue with the AppCheckCore dependency bumped to 10.19.1? #12629 (comment)

@jostster
Copy link
Contributor Author

@ncooke3 I haven't had a chance to implement it as it wasn't available in the latest release version at the time. I am on PTO but will add it into our June release

@google-oss-bot
Copy link

Hey @jostster. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@ShehanRashmika
Copy link

I also getting this error, I didn't change any code, and it worked in the morning.

[log] e.message Error Domain=FIRAuthErrorDomain Code=17999 "An internal error has occurred, print and inspect the error details for more information." UserInfo={FIRAuthErrorUserInfoNameKey=ERROR_INTERNAL_ERROR, NSLocalizedDescription=An internal error has occurred, print and inspect the error details for more information., NSUnderlyingError=0x3029a9fe0 {Error Domain=FIRAuthInternalErrorDomain Code=3 "(null)" UserInfo={FIRAuthErrorUserInfoDataKey={length = 1628, bytes = 0x3c21444f 43545950 45206874 6d6c3e0a ... 2e3c2f69 6e733e0a }, NSUnderlyingError=0x3029a2610 {Error Domain=com.google.HTTPStatus Code=403 "(null)" UserInfo={data={length = 1628, bytes = 0x3c21444f 43545950 45206874 6d6c3e0a ... 2e3c2f69 6e733e0a }, data_content_type=text/html; charset=UTF-8}}}}}


     String? token =
          await FirebaseAuth.instance.currentUser!.getIdToken(force);

@jostster

@ShehanRashmika
Copy link

UPDATE

This error comes when device connect to VPN. If VPN is off its working. What is the issue?

@google-oss-bot
Copy link

Hey @jostster. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@google-oss-bot
Copy link

Since there haven't been any recent updates here, I am going to close this issue.

@jostster if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

@ncooke3
Copy link
Member

ncooke3 commented Sep 16, 2024

Reopening as this is still an issue.

@ncooke3
Copy link
Member

ncooke3 commented Sep 16, 2024

Hi everyone, I have these token failures to Apple (FB13812838) and am still awaiting a response. I will follow-up and report back as I learn more.

@jostster
Copy link
Contributor Author

For confirmation we had one user that updated their iOS version and was locked out because of the AppCheck. We asked them to uninstall our app, then reinstall it from the AppStore and they got back to us saying that reinstalling allowed them to get back in.

@jostster
Copy link
Contributor Author

@ncooke3 is it possible for firebase to request a new token on these failures? With iOS 18 out now, and as users are updating, they are contacting our support with this error that the AppCheck is giving them a 17,999 error. Really the only thing we can try is having them delete the application and reinstall it from the app store and hope that fixes it for them.

@ncooke3
Copy link
Member

ncooke3 commented Sep 19, 2024

Yes @jostster, I will look into this ahead of the next release. I suspect this is due to the SDK storing an app attest artifact in user defaults, which is included in iCloud backups. Since the artifact is device specific, I suspect this may explain this failure path that upgrading customers are experiencing.

@jostster
Copy link
Contributor Author

Thanks @ncooke3 . I'm curious, is there a different key as I created this little hack as a work around which did work before but with this still in our application and users still encountering this error, I was curious if there is another place I should be resetting the token.

#import "FirebaseAppCheckProviderOverride.h"
@import Firebase;
@import FirebaseAppCheck;

@implementation FirebaseAppCheckProviderOverride

- (FBLPromise<NSNull *> *)resetAttestation {
    FIRAppAttestProvider* provider = [[FIRAppAttestProvider alloc] initWithApp:[FIRApp defaultApp]];
    return [provider performSelector:@selector(resetAttestation)];
}

@end

@ncooke3
Copy link
Member

ncooke3 commented Sep 20, 2024

Hi @jostster, I mixed up my thoughts as the retry logic to wipe out the key ID was already implemented last year to address #11926.

Since reinstalling the app seems to fix the issue, I'm trying to tease out what persistent state is the culprit.

Two additional questions to clarify some details.

  • Are you using any other providers beside app attest?
  • Are you using an app group to share data across multiples apps you develop?

@jostster
Copy link
Contributor Author

We do use the debug app attest provider, but that is only for dev builds. For production where we are seeing this issue we only use the default AppAttestProvider(app:). We also do not use App Groups or have that capability enabled.

@jostster
Copy link
Contributor Author

@ncooke3 Would recaptcha be an alternative for AppCheck? Our use for AppCheck is to prevent bad actors from hitting the google api directly and bruteforce logins.

@ncooke3
Copy link
Member

ncooke3 commented Sep 24, 2024

Hi @jostster, reCAPTCHA could be a solution to consider. It is documented to use Apple's App Attest, so if App Attest is the underlying issue here, then similar failures could occur.

When the Auth SDK makes a request (e.g. password login), an app check token is requested to include in the request. Tokens can be requested with and without forcing a refresh of the token. In Auth's case, app check token's are not force refreshed, so whatever token is cached will be included in the request. This is done to be as performant as possible.

In this case though, I think it could make sense to retry the sign in request with a fresh app check token to see if that fixes the issue or at least provides some more clues as to what is going wrong.

Here's an example of what this could look like:

      Task {
        do {
          try await Auth.auth().signIn(withEmail: email, password: password)
        } catch let error as NSError {
          // Catch the App Check related error, force refresh the stored App
          // Check token, and make retry signing in.
          guard error.code == AuthErrorCode.internalError.rawValue else {
            throw error // Error is unrelated (e.g. account does not exist).
          }
          
          // This call will fetch a new app check token and reset the cached
          // attestation artifacts if needed.
          _ = try await AppCheck.appCheck().token(forcingRefresh: true)
          
          // Retry the sign in. This should pick up the new, refreshed token.
          try await Auth.auth().signIn(withEmail: email, password: password)
        }
      }

@jostster
Copy link
Contributor Author

Thanks @ncooke3 I was looking at the app-check repo earlier and noticed this open issue which relates to the token(forcingRefresh: true) returning the cached token if a token(forcingRefresh: false) is in progress. I'm wondering if this might be something causing this issue?

@ncooke3
Copy link
Member

ncooke3 commented Sep 25, 2024

I don't think so because the Auth SDK uses token(forcingRefresh: false) so a cached token will be returned regardless of whether a concurrent token(forcingRefresh: true) is happening.

@ncooke3
Copy link
Member

ncooke3 commented Sep 25, 2024

@jostster, if you would like, I can take a closer look into the logs to better understand which part of the App Attest handshake is failing. I just need a project number. Feel free to send it to nickcooke+gh at google dot com

@jostster
Copy link
Contributor Author

@jostster, if you would like, I can take a closer look into the logs to better understand which part of the App Attest handshake is failing. I just need a project number. Feel free to send it to nickcooke+gh at google dot com

Sent, ty!

@ncooke3
Copy link
Member

ncooke3 commented Oct 7, 2024

Hi @jostster, after a closer look, I think this may be #12468 surfacing when the the Auth SDK requests the App Check token. If the App Check token cannot be successfully retrieved, then the App Check SDK will give a place holder token to include that will result in the error message given. Today I released a fix similar to what was done in #11926. Please take a look at my comment in the corresponding issue for updating instructions: #12468 (comment)

I'm going to mark this issue as closed, but we can re-open if the persists.

@ncooke3 ncooke3 closed this as completed Oct 7, 2024
@firebase firebase locked and limited conversation to collaborators Nov 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants