如何在 PhoneGap Cordova 中重定向到 Google Auth?
How to redirect to Google Auth in PhoneGap Cordova?
我正在研究 Firebase + PhoneGap。我制作了一个简单的 Google Auth 登录系统,它在网络上运行完美 (smart-media-compaing.firebaseapp.com),但是当我通过 PhoneGap 为 Android 制作它的 APK 时,PhoneGap 应用程序( Android) 没有将我重定向到 Google 授权页面。
因为它找不到任何 localserver/other 服务器地址。
如何在 PhoneGap (Android) 应用程序中重定向到 Google Auth?
var provider = new firebase.auth.GoogleAuthProvider();
provider.setCustomParameters({
'login_hint': 'user@example.com'
});
firebase.auth().signInWithRedirect(provider);
firebase.auth().getRedirectResult().then(function(result) {
if (result.credential) {
// This gives you a Google Access Token. You can use it to access the Google API.
var token = result.credential.accessToken;
// ...
var user = result.user;
window.location.replace('profile.html');
}
// The signed-in user info.
var user = result.user;
}).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// The email of the user's account used.
var email = error.email;
// The firebase.auth.AuthCredential type that was used.
var credential = error.credential;
// ...
});
是 Firebase 问题还是 PhoneGap 问题?
尝试使用InAppBrowser插件打开外部网站。
https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/
Phonegap 应用程序使用 file://
协议运行,HTTP 请求总是通过代理服务器,可能代理服务器无法成功处理授权请求。
我正在研究 Firebase + PhoneGap。我制作了一个简单的 Google Auth 登录系统,它在网络上运行完美 (smart-media-compaing.firebaseapp.com),但是当我通过 PhoneGap 为 Android 制作它的 APK 时,PhoneGap 应用程序( Android) 没有将我重定向到 Google 授权页面。
因为它找不到任何 localserver/other 服务器地址。
如何在 PhoneGap (Android) 应用程序中重定向到 Google Auth?
var provider = new firebase.auth.GoogleAuthProvider();
provider.setCustomParameters({
'login_hint': 'user@example.com'
});
firebase.auth().signInWithRedirect(provider);
firebase.auth().getRedirectResult().then(function(result) {
if (result.credential) {
// This gives you a Google Access Token. You can use it to access the Google API.
var token = result.credential.accessToken;
// ...
var user = result.user;
window.location.replace('profile.html');
}
// The signed-in user info.
var user = result.user;
}).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// The email of the user's account used.
var email = error.email;
// The firebase.auth.AuthCredential type that was used.
var credential = error.credential;
// ...
});
是 Firebase 问题还是 PhoneGap 问题?
尝试使用InAppBrowser插件打开外部网站。 https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/
Phonegap 应用程序使用 file://
协议运行,HTTP 请求总是通过代理服务器,可能代理服务器无法成功处理授权请求。