[英]emberfire auth + cordova
As I understood, emberfire auth works via torii and includes the own torii-provider ( torii-providers/firebase.js
). 据我了解,emberfire auth通过torii进行工作,并包括自己的torii-provider(
torii-providers/firebase.js
)。
When I try to sign in, it runs signInWithPopup
method from the firebase provider. 当我尝试登录时,它会从
signInWithPopup
提供程序运行signInWithPopup
方法。 It does not work when the application is running on a mobile device via cordova ( location.protocol
is equal to "file:"
). 当应用程序通过cordova在移动设备上运行时,它不起作用(
location.protocol
等于"file:"
)。
I've found a workaround: 我找到了一种解决方法:
I use the cordova plugin for authorization via google to get idToken. 我使用cordova插件通过Google进行授权以获取idToken。
I've overridden the provider to use signInWithCredential
: 我已覆盖提供程序以使用
signInWithCredential
:
export default ToriiFirebaseProvider.extend({ open(idToken) { const firebaseApp = get(this, 'firebaseApp'); const credentials = get(firebaseApp, 'firebase_.auth.GoogleAuthProvider.credential')(idToken); return firebaseApp.auth().signInWithCredential(credentials); } });
It works now, but I'm not sure that it's the right solution? 现在可以使用,但是我不确定这是正确的解决方案吗?
So, you want a redirect instead of a pop-up? 因此,您要重定向而不是弹出窗口? If that's what you want, just set the redirect option:
如果那是您想要的,只需设置重定向选项:
this.get('session').open('firebase', { provider:'google', redirect: true })
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.