Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get accessToken for firebase 3 using javascript

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?

like image 907
Stradosphere Avatar asked Jun 24 '16 01:06

Stradosphere


People also ask

Does Firebase authentication still persist the access token?

Since Firebase Authentication no longer persists the access token, your application will have to do so itself, if needed. The documentation is pretty clear now: firebase.google.com/support/guides/…

How do I add firebase to a javascript project?

Add Firebase to your JavaScript project. Go to the Service Accounts page in your project's settings. Click Generate New Private Key at the bottom of the Firebase Admin SDK section of the Service Accounts page. The new service account's public/private key pair is automatically saved on your computer.

How do I create a private key for my Firebase account?

Add Firebase to your JavaScript project. Go to the Service Accounts page in your project's settings. Click Generate New Private Key at the bottom of the Firebase Admin SDK section of the Service Accounts page. The new service account's public/private key pair is automatically saved on your computer. Copy this file to your authentication server.

What is Firebase and how does it work?

This magical solution is called Firebase. The Firebase authentication library which is a part of the overall platform makes life easier for both developers and users. As for users, it makes it simpler to register or log in to the app with just a simple click to connect with their social media accounts or the classic email and password solution.


Video Answer


1 Answers

firebase.auth().signInWithEmailAndPassword(u, p).then(function(result){

    result.getToken().then(function(token){
        $rootScope.userLoginToken = token;
    });

});
like image 190
Stradosphere Avatar answered Oct 05 '22 06:10

Stradosphere