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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 [FIREBASE_APP_CHECK] Cant get this to work with ios #6457

Closed
febg11 opened this issue Jun 23, 2021 · 15 comments
Closed

馃悰 [FIREBASE_APP_CHECK] Cant get this to work with ios #6457

febg11 opened this issue Jun 23, 2021 · 15 comments
Labels
platform: ios Issues / PRs which are specifically for iOS. plugin: app_check resolution: duplicate This issue or pull request already exists type: bug Something isn't working

Comments

@febg11
Copy link

febg11 commented Jun 23, 2021

I just bought an apple dev license and have generated an api key with device check enabled.

I have uploaded this to firebase and added the team ID/key ID.

I have then made sure my signing profile is my new account. I have ran flutter clean and pub get. I also deleted the app from my device. I have opened the workspace in xcode and have let it build. It still doesn't authenticate

[firebase_functions/unauthenticated] Unauthenticated
[firebase_storage/unauthenticated] User is unauthenticated. Authenticate and try again.

I have tried adding pod 'Firebase/AppCheck' to the pod file and running pod install as per this doc https://firebase.google.com/docs/app-check/ios but i doubt that is needed with the flutter lib.

Is there something I am missing? Maybe something i need to do in xcode so it allows device check calls?

@febg11 febg11 added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Jun 23, 2021
@varunbhalerao56
Copy link

varunbhalerao56 commented Jun 24, 2021

@febg11 Hey I am having the same problem with android, mind sharing how you got that working. I followed the docs but no luck. (I haven't tried iOS yet but will check that too)

@febg11
Copy link
Author

febg11 commented Jun 24, 2021

@febg11 Hey I am having the same problem with android, mind sharing how you got that working. I followed the docs but no luck. (I haven't tried iOS yet but will check that too)

The thing that made android work for me is removing all sha1 keys from firebase and the app key on the credentials page on gcp. Make sure that no key restrictions are set aswell. Let me know if this works and if you have any luck with iOS

@Salakar
Copy link
Member

Salakar commented Jun 24, 2021

@febg11 have you tried re-downloading and integrating your iOS apps Google Services plist file since you added Apple configs to the Firebase Console?

@varunbhalerao56
Copy link

varunbhalerao56 commented Jun 24, 2021

@febg11 unfortunately I am unable to get it working on both android and iOS. But do try what Salakar commented might help out.

I know this might be a dumb question but when it says pass in a jwt token how do I do that, I already have a jwt token from my gRPC server. I just want to authenticate using firebase's custom token.

When called on ios
image

When called on android
image

Also, this is my callable function, is this the correct way of doing it?

exports.signUpMember = functions.https.onCall(async (data, context) => {

    if (context.app == undefined) {
        throw new functions.https.HttpsError(
            'failed-precondition',
            'The function must be called from an App Check verified app.')      
      }

    const userId = "randomUserID";
 
    console.log ("isUndefined :"  + context.app == undefined)
    console.log("id: " + userId);
    admin
        .auth()
        .createCustomToken(userId)
        .then((customToken) => {
            console.log("token: " + customToken);


            return { token: customToken }
            // Send token back to client
        })
        .catch((error) => {
            console.log('Error creating custom token:', error);
        });});

@febg11
Copy link
Author

febg11 commented Jun 24, 2021

I'm not sure I'm best to answer any of these questions. Your android code looks like it's working though. Notice the App:Valid log. I think this means the app check token was from a valid device

I haven't used custom tokens before so Im not too sure about the rest of this.

You get the same errors as me for iOS. We probably need a flutter Dev to help with these problems

@Salakar the iOS app key has always been used it's just not working with app check. I will double check and generate a new one later today and let you know if it makes any difference

@enri90
Copy link

enri90 commented Jun 24, 2021

not work on Web

#6310

@febg11
Copy link
Author

febg11 commented Jun 24, 2021

@Salakar just tried downloading the googleservices.plist again and its contents are the same as the one I am already using

@markusaksli-nc markusaksli-nc added triage Issue is currently being triaged. platform: ios Issues / PRs which are specifically for iOS. plugin: app_check and removed Needs Attention This issue needs maintainer attention. triage Issue is currently being triaged. labels Jun 25, 2021
@febg11
Copy link
Author

febg11 commented Jun 26, 2021

Somehow got this working on iOS. Honesty not sure whats different

@varunbhalerao56
Copy link

varunbhalerao56 commented Jun 27, 2021

Somehow got this working on iOS. Honesty not sure whats different

@febg11 I know this is too much to ask but do you mind sharing with me the android and iOS folders (without the plist and json files ofc). I think I am messing up the platform integrations, as I have no mainActivity.java instead using mainActivity.kt

@seanyyyyyy
Copy link

seanyyyyyy commented Jul 12, 2021

got this working on iOS today (Note: i only have App Attest enabled in Firebase, not Device Check),

Steps i was missing:

  • In Xcode, add the *App Attest capability to your app.
  • In your project's .entitlements file, set the App Attest environment to production.
  • build and run through Xcode then I can see the Firebase App Check debug token in Xcode logs (it doesn't appear in my IntelliJ logs for some reason...)
  • copy this token and set it as debug token in Firebase (also it seems each Simulator device has a different token value which needs to be added)

Reference: https://firebase.google.com/docs/app-check/ios-app-attest

@wazini-john
Copy link

@seanyyyyyy How does one build a flutter app through xcode?

@seanyyyyyy
Copy link

@seanyyyyyy How does one build a flutter app through xcode?

open up the Runner.xcworkspace file in the ios directory, choose your target device/simulator and press the Run button

@wazini-john
Copy link

@seanyyyyyy How does one build a flutter app through xcode?

open up the Runner.xcworkspace file in the ios directory, choose your target device/simulator and press the Run button

Do you have like a step by step list I can follow to generate the token ?
All I'm getting is a SQFlite error Undefined symbol: _OBJC_CLASS_$_FMDatabaseQueue
Kinda new to xcode

@wazini-john
Copy link

They have fixed it

@markusaksli-nc
Copy link
Contributor

The functions issue has been addressed in #6794 and storage is a duplicate of #6551

@markusaksli-nc markusaksli-nc added the resolution: duplicate This issue or pull request already exists label Aug 24, 2021
@firebase firebase locked and limited conversation to collaborators Sep 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform: ios Issues / PRs which are specifically for iOS. plugin: app_check resolution: duplicate This issue or pull request already exists type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants