Search code examples
javascriptfirebaseionic-frameworksupabase

Can I Auth a user through Firebase and use Supabase (private) buckets without relying on Supabase Auth users limitation


I have an Ionic application that use a pretty small file(1kb) to store user info. I want to implement cloud backup for it. The user just need to download it once, when restoring backup. All other operations are uploads.

Firebase can provide Auth, but the amount of Cloud Storage upload operations aren't enough. (my app does upload several times)

Supabase is more generous on storage its storage, but I have about +50k users. So can't use its Auth features.

I also tried Google Sign-in and access on Google Drive. Which has a free specific app-folder. However, couldn't get any example on how to access this folder (download/upload) through JavaScript.

Even using Gapi. Which I tried through this repo(ng-gapi)

So, my question is: Can I Auth a user through Firebase and use Supabase (private) buckets (since the file access must be authenticated) without relying on Supabase Auth users limitation?


Solution

  • It is possible to auth to firebase by using following example:

    FirebaseAuthentication.signInWithGoogle({
        skipNativeAuth: true,    //Important to enable skip native auth
        scopes: ["email", "profile", "openid"],
      }).then((result) => {
        console.log(`Login Result: ${JSON.stringify(result)}`)
        firebaseAuth(result.credential.idToken)
      }).catch((reason) => {
        console.error`Login Error: ${JSON.stringify(reason)}`
      }).finally(() => {
        console.log(`Finished Log In`)
      })
    

    The resolve callback is going to provide the Provider ID Token ( Google.com ) and the authorization code which can be used to auth to supa & to firebase. This allows to use both backends with 1x auth.