Scenario
I want to
pass the Authentication from Android Native app which was done via FirebaseAuth
TO
html/javascript screens which are being embedded as Webview
in my app, so that i can call my Firebase DB without asking user to relogin.
What I Tried
i tried to signIn using signInWithCustomToken and used the token generated from getidtokenresult which throws error "INVALID_CUSTOM_TOKEN"
Any guidance will be helpful
You can use the Firebase Admin SDK in your Native app to generate a valid token for your client app to use with signInWithCustomToken()
Token Generation:
//The uid should uniquely identify the user or device you are authenticating
String uid = "some-uid";
String customToken = FirebaseAuth.getInstance().createCustomToken(uid);
// Send token back to client
Use in client app:
firebase.auth().signInWithCustomToken(token).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
});
There is further information about this in the Firebase docs