Firebase REST API auth - access token

I have to use Firebase Database and server a REST API .I need to allow the REST API call only for authenticated users from the same freebase.

According to Documentation on REST API Save data > Auth Section I able to successfully access the Database using database secret .

https://firebase.google.com/docs/database/rest/save-data

But I could not successfully retrieve the data using access token of authenticated user .

https://<<removed-my-project-id>>.firebaseio.com/users.json?access_token=ya29.GlxuBLxJ6R2uNYJ7SXnMhe7Inqw94ShGeZ7MTBmyxYUI2cLDCXJcPAfbo1_uKLjUhfPX3uQw_ElBjIVwu73caeKJfBAh87GGRWZx2JiSwuIZybAmtVXyFyqaeYbAJQ

Reffering confusing document again I pass the URL as fallows using the idtoken.(currentUser.getIdToken taken from cleint side)

https://<<my-project-id>>.firebaseio.com/users.json?auth=eyJhbGciOiJSUzI1NiIsImtpZCI6IjBkNWNlYjA1ODA2ODk3OTM3ZTAxNGFjMDNkYWZkODQyMzM4ZjBlNmQifQ.eyJpc3MiOiJodHRwczovL3NlY3VyZXRva2VuLmdvb2dsZS5jb20vZmV0Y2htZS1iYWNrZW5kLTFmOGQyIiwibmFtZSI6IkthbmNoYW5hIEd1bmF0aGlsYWthIiwicGljdHVyZSI6Imh0dHBzOi8vbGg0Lmdvb2dsZXVzZXJjb250ZW50LmNvbS8tLUNwc21oa3JzcUUvQUFBQUFBQUFBQUkvQUFBQUFBQUFBQUEvQUF5WUJGN3BtRTBuNHBxLThid3lmdEFYUjVCb2F6X2JTQS9zOTYtYy9waG90by5qcGciLCJhdWQiOiJmZXRjaG1lLWJhY2tlbmQtMWY4ZDIiLCJhdXRoX3RpbWUiOjE0OTc4NzM2NzMsInVzZXJfaWQiOiI5aG1lMjIzT0hNWXRGN0VUME9ud2xXaVJkSjAyIiwic3ViIjoiOWhtZTIyM09ITVl0RjdFVDBPbndsV2lSZEowMiIsImlhdCI6MTQ5NzkzNzIzMSwiZXhwIjoxNDk3OTQwODMxLCJlbWFpbCI6Im1ka3NhbmthbHBhYW5kcm9pZEBnbWFpbC5jb20iLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiZmlyZWJhc2UiOnsiaWRlbnRpdGllcyI6eyJnb29nbGUuY29tIjpbIjEwOTM4NDg4ODYyMDc5MzEwOTc3MSJdLCJlbWFpbCI6WyJtZGtzYW5rYWxwYWFuZHJvaWRAZ21haWwuY29tIl19LCJzaWduX2luX3Byb3ZpZGVyIjoiZ29vZ2xlLmNvbSJ9fQ.iq7mtF_a9DiApole4w2NdF4ndjHF-BJA1E7W0N_RrffoA5Iz2E-SoNqcIj8s6fv4PM_5S_w127A_B2woiblbt4VXrZE6wxUMQIurzmLMs-dehs5XZZTqG4t94fgFnRteTfz6icMbYbk5-aavl_-eRkj3PpRigGA5MIcc6VaE6kyo_9FlkxAxzuMS9Z7xhVqeFo5CU6peyewf2MNCDI7_tsBoT8P1YniyDAYd5HFQNyhg0ezEKeuUlFhG7d35TyaURpXNtqOknvYil1jgCPVO0r63PspZI8XUWOqq8NCZ4jE0KxGmKH55eF1vGkCeA2F8mP9yQvXAEezdEeSo-f7vlg


It is a scuesss

To get token from Web client yu can use the following code.

       firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idToken) {
                       console.log('idToken'+idToken);
})


Comments

Popular posts from this blog

ENOENT: no such file or directory, rename : node_modules/async

react-quill Integrate quill-image-resize-module