Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
212 views
in Technique[技术] by (71.8m points)

Why can't I login into my cordova application using firebase twitter or facebook providers?

I'm developing a cordova application with ionic using firebase as a backend and I'm trying to authenticate my users using the twitter and facebook authentication providers offered by firebase. I'm using firebase's Javascript SDK. I apologize if this question has already been answered here, but I haven't found any helpful answer so far.

I've setup all the required information in our twitter and facebook developer apps, and set up firebase dynamic links and my application as specified here:

https://firebase.google.com/docs/auth/web/cordova

So far, I've been able to call the twitter and facebook providers in redirection mode, via

  firebase.auth().signInWithRedirect(provider);

as the popup mode is not supported yet in cordova applications via the following code (as specified in https://firebase.google.com/docs/auth/web/cordova ).

const provider = new firebase.auth.TwitterAuthProvider();
firebase.auth().useDeviceLanguage();
firebase.auth().signInWithRedirect(provider).then(() => {
  return firebase.auth().getRedirectResult();
}).then((twitterLoginResult) => {
  console.log(twitterLoginResult);
});

However, after following the authentication steps in the provider screen, I'm encountering two problems.

  1. Twitter. After granting access to my twitter application and authenticating the user, I'm taken to an error page with the message "Sorry, that page doesn't exist!". The URL for that page is api.twitter.com/login, so I'm guessing the "login" API called doesn't exist anymore. However, I remember it working (that is, going back to my application instead of showing me this page) sometimes, but then stop working suddenly.
  2. Facebook. After authenticating the user, I'm taken to a blank screen. This is documented in https://github.com/firebase/firebase-js-sdk/issues/2103 , but using the cordova-plugin-background-mode plugin is a no-no as it could lead us to have our application rejected by Apple (plus that plugin seems to be discontinued). I've already tried what is recommended in https://github.com/firebase/firebase-js-sdk/issues/2103#issuecomment-590750609 , but the white screen remains.

Because of these problems, the signInWithRedirect result is never received and the user authentication can't be performed.

This seems to be quite a common thing to do (authenticating a cordova application via the firebase providers), but I can't seem to find any good information about how to fix these problems. What I'd like to know is:

  1. Is it possible to authenticate a user in a cordova application using twitter or facebook firebase providers?
  2. If so, how can I avoid the problem with the white screen while accessing the facebook provider and the redirection to a non-existent api page when using the twitter provider? If possible, a code snippet would be highly appreciated.
  3. Do you know of any tutorial or web page where the login process via the firebase javascript sdk is explained in detail?

As a side note, about the twitter authentication, using firebase's javascript sdk or a cordova plugin to takes me to the same non-existent API page.

Below you can find firebase documentation pages for the twitter and login providers. https://firebase.google.com/docs/auth/web/twitter-login

https://firebase.google.com/docs/auth/web/facebook-login

Thank you very much for your help

question from:https://stackoverflow.com/questions/66048139/why-cant-i-login-into-my-cordova-application-using-firebase-twitter-or-facebook

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...