I need to make a shallow rest call using javascript with firebases REST Api, in the past version I needed to pass the access token like this:
var authKey = ref.getAuth().token;
var s = firebaseUrl + '/.json?shallow=true&auth=' + authKey;
$http.get(s)
How do I do this now with firebase 3?
I need to make a shallow rest call using javascript with firebases REST Api, in the past version I needed to pass the access token like this:
var authKey = ref.getAuth().token;
var s = firebaseUrl + '/.json?shallow=true&auth=' + authKey;
$http.get(s)
How do I do this now with firebase 3?
Share Improve this question edited Jun 24, 2016 at 1:35 Frank van Puffelen 599k85 gold badges888 silver badges858 bronze badges asked Jun 24, 2016 at 1:11 StradosphereStradosphere 1,2853 gold badges14 silver badges40 bronze badges 1- just to clarify, this is asking about the firebase jwt token and not the auth provider's access token. The firebase jwt token is used for firebase authentications and the auth provider's access token is used for provider authentication and accessing the provider's apis (e.g. drive API for google) – Jason Commented Dec 7, 2021 at 23:10
2 Answers
Reset to default 13firebase.auth().signInWithEmailAndPassword(u, p).then(function(result){
result.getToken().then(function(token){
$rootScope.userLoginToken = token;
});
});
The access token is no longer available in the authData when you're using version 3.x of the SDK. But you can get is when the user gets authenticated with.
var auth = firebase.auth();
var provider = new firebase.auth.GoogleAuthProvider();
auth.signInWithPopup(provider).then(function(result) {
var accessToken = result.credential.accessToken;
});
For this and a lot more information that is relevant when migrating your web app, see the upgrade guide for web apps (where I copied the code from).