Daniel Paulo de Assis
Daniel Paulo de Assis

Reputation: 51

OAuth SignIn Cordova Firebase

I tried to use OAuth SignIn Cordova Firebase in a hybrid cordova app following the steps from this firebase tutorial:

Authenticate Using OAuth Providers with Cordova

But I did not succeed and get the error message below:

Error: {"code":"auth/operation-not-supported-in-this-environment","message":"This operation is not supported in the environment this application is running on. \"location.protocol\" must be http, https or chrome-extension and web storage must be enabled."}

Upvotes: 2

Views: 1152

Answers (2)

I was getting same error when I was using signInWithPopup, so I followed all steps mentioned here https://firebase.google.com/docs/auth/web/cordova, installed all plugins and used signInWithRedirect and it worked for me in iPhone but not in iPad so I found its navigator.userAgent issue firebase expects "ipad" but it does not contains "ipad". So I fixed like this

if (navigator.userAgent.includes('Macintosh') && 'ontouchend' in document) {
      Object.defineProperty(navigator, 'userAgent', {
        value: navigator.userAgent.replace('Macintosh', 'iPad'),
        configurable: true,
      });
    }

And it worked for iPad too.

Upvotes: 0

Daniel Paulo de Assis
Daniel Paulo de Assis

Reputation: 51

I found the solution, the issue was corrected in the latest Firebase JavaScript SDK release (4.1.3)

Firebase JavaScript SDK Release Notes

Upvotes: 0

Related Questions