Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

273
Views
Getting firebase realtime database sending an oauth token (Angular iframe)

I currently have an iframe which i embeed in my site, in a chrome extension and in 3rd party sites.

The problem is the following: I'm populating parts of my iframe with firebase data. In my site, i embeed my own iframe and is protected by a firebase token (the views), i don't know exactly how it works, but it returns the data correctly when calling the DB. Example:

 getData(
    reference: string,
  ){
    const ref = `accounts/${reference}`;
    const dataReturn = this.db.object(ref).valueChanges();
    return dataReturn;
  }

This returns just fine on my webapp, when the user logouts in my webapp, then the data is protected (as it has to be)

The problem begins here: When a 3rd party embeeds my iframe, they use an oAuth token (to get users, etc from my API), so they're not logged in my website, hence, when they embeed and try to get the data (automatically, since we call firebase onInit), they get blocked by firebase because they don't have a valid token/they're not authenticated in my website.

Is there a way to use that oAuth token to let them get the firebase data?

Same escenario happens in the chrome extension, we make the user log-in using an oAuth token (to prevent making an account and logging in in our webapp, preventing CORS issues).

These are my rules in realtime database firebase:

"accounts": {
            ".read": "auth !== null",
            ".write": false,
    }

Thank you!

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

If the OAuth token is from a collaborator on the Firebase project and that collaborator has access to the Realtime Database, the client will have that same access to the database too.

Their API calls will in that case bypass the security rules of your database, just as when the collaborator would sign in to the Firebase console and access the database there.

about 4 years ago · Juan Pablo Isaza Report

0

Ok.. so for anyone wondering.. a coworker resolved this issue by sending the oAuth token to our backend, and returning from there a valid firebase token. With that token, we just sign-in with signInWithCustomToken() firebase function (of course applying logic so just oAuth users can actually use this automatically). That way my users have access to realtime database since they're authenticated in firebase

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!