-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught Error: "location.protocol" must be http or https when building to device using Ionic 2 & Angular 2 #243
Comments
here is a project where I am running into issues - https://github.com/aaronksaunders/ionic2-angularfire-sample/tree/firebase3-support Issue appears to be around anything that you need to subscrbe to, I am creating a very basic app to demonstrate the issue. I am getting errors thrown around I created a smaller project that shows the issue without all the extras: https://github.com/aaronksaunders/basicaf2 |
Has anyone found a way around this error? Seems like this error is making angularfire useless for cordova apps. |
Facing same issue ! |
As @aaronksaunders said, it has to do with Whenever you subscribe to a method from firebase, this is including their and yeah, @Chuckv01 having the same issue here, switched my app to use localStorage for & probably going to use another Authentication provider or service unless they fix this issue rapidly (easy to switch services). |
Can use previous versions of AngularFire to avoid this issue? Need to wait until they fix it. |
@mithunvp yes, you can use previous version of AngularFire 2 with Firebase SDK v2.4.2, Until they fix this issue. |
With Firebase SDK 2.4.2, I will have to use legacy Firebase site not the new firebase.google.com site, I am little confused here? |
True, you have to use legacy Firebase console :( :(, but it's a matter of some days until they figure it out. |
I believe this issue is in the Firebase SDK itself, since the AngularFire2 codebase doesn't access @aaronksaunders or @nickkenens can either of you try using the new Firebase SDK without AngularFire2 and see if the problem still occurs? I'll see if I can run @aaronksaunders project to repro the issue. |
@jeffbcross i just tried it with the just the Firebase SDK and it works fine... |
Thanks I wasn't able to get the reproduction running before I left the
|
I have traced up to firebase.js. Seems it is a problem with SDK - it checks protocol to be http or HTTPS and in ionic2 environment protocol is file:// However I did not checked with pure SDK as @aaronsaunders did. Strange - may be we are using different GB SDKs... |
This issue also don't allow to use Firebase authentication... It is really critical for my app. Any workarounds? |
Facing the same issue with Ionic v1 |
Found the issue: https://firebase.google.com/docs/reference/js/firebase.auth.Auth#getRedirectResult The error is listed on that page. Auth is calling that method to see if the app is being loaded as an oauth redirect. We could add a protocol check before calling the method. |
When using AngularFire in non-browser environments, such as Ionic, subscribing to the AngularFireAuth service would cause an error to be thrown. This was because getRedirectResult() is always called at the beginning of the auth observable, to determine if the page is being loaded after a redirect-based oAuth flow. However, calling this method is not supported if location.protocol is not http or https. In the case of Ionic, the protocol is file:. This change adds a check before calling getRedirectResult to make sure the protocol is http or https. BREAKING CHANGE: The AngularFireAuth class has changed the order of its constructor arguments. Since this is usually instantiated automatically via dependency injection, it shouldn't affect common usage of the library. However, if manually instantiating AngularFireAuth in tests or in an application, the order of arguments is now: AuthBackend, WindowLocation, Fixes angular#243
I have same error when trying auth with pop-up, not reflect. That should work (and was working on previous SDK) on Ionic2... |
@olostan the error occurs as soon as subscribing to auth because AngularFire is calling |
When using AngularFire in non-browser environments, such as Ionic, subscribing to the AngularFireAuth service would cause an error to be thrown. This was because getRedirectResult() is always called at the beginning of the auth observable, to determine if the page is being loaded after a redirect-based oAuth flow. However, calling this method is not supported if location.protocol is not http or https. In the case of Ionic, the protocol is file:. This change adds a check before calling getRedirectResult to make sure the protocol is http or https. BREAKING CHANGE: The AngularFireAuth class has changed the order of its constructor arguments. Since this is usually instantiated automatically via dependency injection, it shouldn't affect common usage of the library. However, if manually instantiating AngularFireAuth in tests or in an application, the order of arguments is now: `(AuthBackend, WindowLocation[, AuthConfiguration])`. Fixes angular#243
I've published a preview of the changes I made in #271 to npm. Can folks here please Note: this has been published with the |
@jeffbcross just checked it and it works |
When using AngularFire in non-browser environments, such as Ionic, subscribing to the AngularFireAuth service would cause an error to be thrown. This was because getRedirectResult() is always called at the beginning of the auth observable, to determine if the page is being loaded after a redirect-based oAuth flow. However, calling this method is not supported if location.protocol is not http or https. In the case of Ionic, the protocol is file:. This change adds a check before calling getRedirectResult to make sure the protocol is http or https. BREAKING CHANGE: The AngularFireAuth class has changed the order of its constructor arguments. Since this is usually instantiated automatically via dependency injection, it shouldn't affect common usage of the library. However, if manually instantiating AngularFireAuth in tests or in an application, the order of arguments is now: `(AuthBackend, WindowLocation[, AuthConfiguration])`. Fixes #243
@Chuckv01 i think your issue is a related but a separate issue... related to auth methods that require a popup. In the previous versions the inappbrowser was integrated in the lib to support this functionality |
@aaronksaunders Hmm, I already have the inappbrowser plugin installed in my project. I also gave it a try using AuthMethods.Redirect, but still got the protocol error. |
Is there a workaround for this? |
@aaronksaunders Would you by chance have this inappbrowser workaround implemented in angularfire2? |
@nelsonad as for now, the only workaround I know is to use https://github.com/nraboy/ng2-cordova-oauth and then https://firebase.google.com/docs/auth/web/twitter-login#handle_the_sign-in_flow_manually |
I'm also still having this issue with angularfire2@2.0.0-beta.3-0930330 |
Solved using Firebase only. Check this: |
jsuarezs solution worked. but it requires more effort to handle login and logout. Is there an ETA on when firebase team would allow file:// for ionic? |
Using angularfire2@2.0.0-beta.3-0930330 fixed my "blank page" issue and I'm able to use the email login of firebase. Facebook and google auth are still broken tho :( |
@jlsuarezs , Can you add the code snippet that you used for facebook login... I tried to follow the firebase doc but am not successful. |
@harpreet2602 check out @aaronksaunders solution https://github.com/aaronksaunders/basicaf2 This worked for me. |
using external auth plugin especially the native one is an interesting option yet this is a workaround and needs additional development especially when the app relays on various auth providers like facebook, google, twitter... |
@ciekawy i think that integrating it directly into angularfire2 is the wrong approach for mobile solutions, I believe the correct approach it to provide integration points, like they have and leave it at that... |
Ref: rodrigoreal/ionic3-angularfire-login#4 |
@aaronksaunders I fully agree that from architectural point of view it is better to provide external integrations. However one of the factors to use firebase for my ionic project especially in the early stage was that the authentication (an for a number of providers) was given out of the box. @harpreet2602 I was able to configure Facebook app to use the approach, yet this is still not a real solution but rather workaround or a replacement - it works just for Facebook (I've managed to make a google plus as well - will try to prepare a PR for that) and requires additional plugin. still main point is that the real issue concerns firebase SDK |
Is a permanent fix in the works? I only use af for the typings and still get this issue. I don't really want to add more complexity by having more libraries handling auth. |
the response I got from firebase support
I guess it's worth asking for the access to firebase SDK sources... |
There's a commit not too far back in the tests about a provider for It seems firebase is checking aspects of the location object but is doing Because of these inconsistent checks I think proceeding with firebase or (Wrote from phone)
|
Any word on a real fix yet besides the work around??? This issue's been open for a while now and I've seen it come up a lot of other places on the web. |
As far as I know, no. In Gitter and other chats, this issue is one of top referenced, but there is no any good workaround or fix. |
I got the same issue with Electron, Ionic 1 and Ionic 2. |
Still having issues in Ionic 2. |
Seems like a serious ongoing issue, have been in love with the library as I've been working with it but it's sad that we can't use it in Electron or Ionic 2 style apps. |
do we have a fix for this yet? thanks! |
anybody to solved this issue? |
@jeffbcross any updates for this issue? |
Just tested on latest angularfire2, Still it is not posible to use Firebase3 Auth with angularfire2 on ionic 2 Got using angularfire2@next (angularfire2@2.0.0-beta.5-preview ) @jeffbcross @davideast should I create new issue or this one could be re-opened? |
Hi Folks. This is an issue with the Firebase SDK and how it handles So, long story short: It's complicated and it's not in AngularFire's purview to solve this. With that in mind, I'm locking this thread to prevent further "is this fixed yet" questions. For quick reference, here are the key discussions from this thread and possible solutions: @olostan correctly suggests that some of the auth problems can by bypassed by using nraboy/ng2-cordova-auth and then calling signInWithCredential() as shown in this example. @jlzuarezs correctly points out that one can bypass some of the redirect issues and auth methods by calling the OAuth methods directly as described here @aaronksaunders suggests aaronksaunders/basicaf2 |
Error in question:
This operation is not supported in the environment this application is running on. "location.protocol" must be http or https.
This error only occurs when the app is built & running on a device. In the browser it works great (which is logical).
Maybe there's a way to manually set the location.protocol on a cordova app using Ionic 2?
The text was updated successfully, but these errors were encountered: