Skip to content

FR: Calling an Apple Revoke Token endpoint #9906

Closed

Description

@linkillhz

Feature proposal

  • Firebase Component: Auth

Apple's new guidelines say,
If your app offers sign-in with Apple, you must use sign-in with the Apple REST API to revoke your user token when you delete your account.
https://developer.apple.com/news/?id=12m75xbj

Does Firebase Auth offer any functionality to assist with account deletion?

Activity

  1. linkillhz commented on Jun 14, 2022

    @linkillhz
    Author
  2. peterfriese commented on Jun 14, 2022

    @peterfriese
    Contributor

    Hi @linkillhz -

    you can delete user accounts in Firebase Auth using user.delete():

    if let user = Auth.auth().currentUser {
      do {
        try await user.delete()
      }
      catch {
        print(error)
      }
    }

    See the docs for more details.

    To delete any of the user's associated data, you can use the Delete User Data Extension. This essentially is a Cloud Function that will run whenever a Firebase Auth user account is deleted (either using the call above or via the Firebase console), and can delete the user's data in Cloud Firestore, Cloud Storage, and the Realtime Database.

    If you find that your data model is different from what the Extension currently supports:

    1. Please consider leaving feedback on the Firebase Extensions repo (file a feature request outlining how your data model looks like)
    2. Consider implementing your own Cloud Function based on the code of the Delete User Data Extension

    As for revoking the token, @rosalyntan and @renkelvin can provide more details.

  3. linkillhz commented on Jun 15, 2022

    @linkillhz
    Author

    Hi, @rosalyntan and @renkelvin

    Firebase SDK did not call Apple's revoke token endpoint when I deleted my Firebase account.
    I have a few questions.

    • What should be the flow for calling Apple's revoke token endpoint when deleting a Firebase account?
      Do I need to implement my own Cloud Function?
      Also, can I get the necessary parameters for Apple's revoke token endpoint?

    • Are there any plans to support calling Apple's revoke token endpoint in the Firebase SDK?

    Regards

  4. CalHoll commented on Jun 16, 2022

    @CalHoll

    +1 Apple is complaining about this being a requirement June 30th. Looks like apps wont be accepted after that date if they do not delete tokens. This is the message:

    Starting June 30, 2022, apps submitted to the App Store that support account creation must also include an option to initiate account deletion.

    We noticed this app may support account creation. If it does not, you may disregard this message. If it already offers account deletion or you’re working to implement it, we appreciate your efforts to follow the App Store Review Guidelines. Apps submitted after June 30 that do not comply with the account deletion requirements in guideline 5.1.1(v) will not pass review.

    Learn more about the account deletion requirements. If your app offers Sign in with Apple, use the Sign in with Apple REST API to revoke user tokens.

  5. Paco777 commented on Jun 17, 2022

    @Paco777

    +1 this is a real problem to be addressed before June 30.
    Either implement it automatically in the SDK (would be great) or give us access to the requested parameters so we can do it ourselves.

  6. CalHoll commented on Jun 18, 2022

    @CalHoll

    I don't think it makes sense to offer this with Firebase SDK. This is something the developer has to handle independently with apple auth. You can get the client secrets and token strings during login or sign up. It is decoupled from the Firebase flows.

    However, apple has provided very poor documentation for how to implement this. Even if you test their API with something like postman, you will always get status code 200 even with incorrect parameters.

    Perhaps you could help explain how this could be implemented, for clarity, I'm using Firebase & Flutter, I use Firebase Auth with flutter and sign_in_with_apple to authenticate with Firebase via the method in the documentation: https://firebase.google.com/docs/auth/flutter/federated-auth

    To delete my user, the documentation for firebase/flutter states to call user.delete().

    This however would cause an app rejection via Apple's new policy. Is your position that users should know to create their own server outside Firebase, track secrets there after authenticating on Firebase, and then call that server to revoke tokens alongside the calls to firebase to delete the authenticated user?

    If so where should that be documented and would a cloud function and Firestore be fine to use to keep track of tokens and revoke on delete?

  7. peterfriese commented on Jun 18, 2022

    @peterfriese
    Contributor

    Hi all -

    Thanks for raising this issue - we are aware of this and are actively working on a solution. We will update this issue once we can share more details.

    Documentation (and accompanying sample code) would definitely be part of the solution. This will likely be a blog post that shows how to use our solution, fast-followed by an update of our docs (https://firebase.google.com/docs/auth/ios/apple).

    We would want to avoid developers having to stand up their own servers outside of Firebase - this would defeat the whole purpose of an mBaaS platform.

  8. jooyoungho commented on Jun 20, 2022

    @jooyoungho

    Apple's revoke API is called based on JWT signed by the developer's key, so I think it will be difficult for the client to implement the function. I think it's most intuitive to upload a key file from the Firebase console (like cloud messaging) and automatically process it when user.delete(). However, with Apple's instruction request date just around the corner, the way to generate JWT and invoke API via Firebase functions seems not bad.

  9. 43 remaining items

  10. peterfriese commented on Apr 20, 2023

    @peterfriese
    Contributor

    This will be launching in the next release of the Firebase SDK.

  11. added this to the 10.9.0 - M131 milestone on Apr 20, 2023
  12. paulb777 commented on Apr 20, 2023

    @paulb777
    Member

    Actually, my understanding is that this was fixed in #11001 and already released in 10.8.0.

    cc: @renkelvin

  13. removed this from the 10.9.0 - M131 milestone on Apr 20, 2023
  14. CristianMoisei commented on Apr 20, 2023

    @CristianMoisei

    @paulb777 Just to confirm, is the expected behaviour that calling Auth.auth().currentUser.delete { .. } should revoke the token automatically also? I tested this now so using 10.8.1, called delete but the token still appears in the apple id page. Could it be because the app isn't live on the app store?

  15. peterfriese commented on Apr 20, 2023

    @peterfriese
    Contributor

    Note: [UPDATE]
    The documentation has been updated. In particular, see steps 2 and 3 in Configure Sign In with Apple, as well as the Token Revocations section

    Hi @CristianMoisei - token revocation needs to triggered separately from deleting the user account.

    We're currently working on updating the docs (and a video is also on the way), but broadly speaking, you will have to do the following:

    1. Make sure you filled out the Services ID and OAuth code flow configuration
      section of the Sign in with Apple provider configuration in the Firebase console

    2. Since Firebase does not store user tokens when users are created with Sign in with Apple, you must ask the user to sign in again before revoking their token and deleting the account. To avoid confusing users, you should show a dialog first, telling the user that they need to authorize deleting their account. For an example of how to do this, have a look at the Craft app

    3. Obtain the authorization code from the ASAuthorizationAppleIDCredential, and use it to call Auth.auth().revokeToken(withAuthorizationCode:) to revoke the user's tokens.

    4. Finally, delete the user account (and all associated data)

    This works independently of whether your app is in the App Store or not.

  16. TheoBo commented on Apr 21, 2023

    @TheoBo

    I try to understand Peter's recommendations, but do not understand how to get ASAuthorizationAppleIDCredential. We use flutter with firebase_auth.

  17. peterfriese commented on Apr 21, 2023

    @peterfriese
    Contributor

    I try to understand Peter's recommendations, but do not understand how to get ASAuthorizationAppleIDCredential. We use flutter with firebase_auth.

    I've filed a feature request on the FlutterFire repo for you, @TheoBo

  18. teeeeeegz commented on Apr 29, 2023

    @teeeeeegz

    Thank you @peterfriese, works great!

    I was wondering what would be best practice for handling token revocation while using the local Firebase emulator?

    When attempting to revoke the token with the Auth.auth().revokeToken(withAuthorizationCode: authCode) function, FIRAuthErrorDomain 17004 error is thrown which refers to "ERROR_INVALID_CREDENTIAL".

    Would simply skipping the above function be the way to go if the local emulator is being used?

    Thanks!

  19. igorzhukov commented on May 8, 2023

    @igorzhukov

    @peterfriese sorry, but Auth.auth().revokeToken(withAuthorizationCode:) method is absent in the latest master branch.

    I imported FirebaseCore, FirebaseAuth

  20. peterfriese commented on May 8, 2023

    @peterfriese
    Contributor

    @peterfriese sorry, but Auth.auth().revokeToken(withAuthorizationCode:) method is absent in the latest master branch.

    I imported FirebaseCore, FirebaseAuth

    It should be there: https://github.com/firebase/firebase-ios-sdk/blob/8efafcb340eb097f4faa2a3c24e46185ff28b28e/FirebaseAuth/Sources/Public/FirebaseAuth/FIRAuth.h#LL858C31-L858C31 - can you double check you're either on master or on 10.8.0 or higher?

  21. igorzhukov commented on May 8, 2023

    @igorzhukov

    @peterfriese sorry, but Auth.auth().revokeToken(withAuthorizationCode:) method is absent in the latest master branch.
    I imported FirebaseCore, FirebaseAuth

    It should be there: https://github.com/firebase/firebase-ios-sdk/blob/8efafcb340eb097f4faa2a3c24e46185ff28b28e/FirebaseAuth/Sources/Public/FirebaseAuth/FIRAuth.h#LL858C31-L858C31 - can you double check you're either on master or on 10.8.0 or higher?

    thank you, it's on the master for spm.

    did you update Cocoapods btw?
    which version/branch should I use for pods Firebase and FirebaseAuth?

  22. paulb777 commented on May 8, 2023

    @paulb777
    Member

    CocoaPods and SPM use the same versioning. We release them at the same time.

  23. locked and limited conversation to collaborators on Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions