简体   繁体   中英

Is there any way to use the same anonymous authentification for Firebase in main App and extension?

My app is using Firebase authentification to store data in the firebase realtime database. This should be done by the main app and by my extension. The problem is that it seems to create two different users, one for the main app, and one for the extension. I just login like this:

Auth.auth().signInAnonymously() { (user, error) in
    MyVariables.uid = user!.uid
}

Is there any way to share the user? I use the same plist for the main app and extension (via appgroup). It also works to write into the database - just with different user IDs.

You can get the token of the anonymous user with FIRUser.getIDTokenWithCompletion: . The find a secure way to pass that from the app to the extension (or vice versa) and pass it to FIRAuth.signInWithCustomToken:completion: . Note that I haven't tried this myself (hence the lack of actual code), but it should work.

Update : Bad news. I checked with one of the our Auth engineers and it turns out that there's no API that allows passing a token to an extension that you can then use there to sign in. Sorry about that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM