我打算使用谷歌的Firebase處理我的網站身份驗證,但我找不到任何關於如何在我的頁面上嵌入谷歌登錄按鈕的文檔。我不打算嵌入默認platform.js腳本,因爲它不用於處理身份驗證。如何使用Firebase嵌入谷歌登錄按鈕進行身份驗證
所有功能正在由firebase處理。另外,我計劃使用自定義用戶界面,而不是Web上的Firebase用戶界面。
按鈕文本也應該針對不同的註冊和登錄按鈕模式進行自定義。
我打算使用谷歌的Firebase處理我的網站身份驗證,但我找不到任何關於如何在我的頁面上嵌入谷歌登錄按鈕的文檔。我不打算嵌入默認platform.js腳本,因爲它不用於處理身份驗證。如何使用Firebase嵌入谷歌登錄按鈕進行身份驗證
所有功能正在由firebase處理。另外,我計劃使用自定義用戶界面,而不是Web上的Firebase用戶界面。
按鈕文本也應該針對不同的註冊和登錄按鈕模式進行自定義。
您是否正在使用適用於Firebase的angularfire,如果您沒有使用它,請嘗試通過此鏈接firebase Google Sign In Method。
Firebase Google登錄的工作原理是,如果用戶不在Firebase中,它會創建一個新用戶。如果用戶存在,則認證不會創建用戶。所以你不必擔心登錄和註冊。只需提供Google登錄即可。例如,考慮這種情況。如果我是Google登錄的新用戶,它會要求我登錄Gmail帳戶,一旦登錄,它將永遠不會再要求我登錄,除非我註銷,如果下次登錄時在按谷歌登錄,它會自動登錄我進去
如果您尋找與按鈕登錄代碼,請像下面的代碼吧,
<input type="button" onclick=callGoogleSignIn() value="Google Sign In"/>
<script>
function callGoogleSignIn(){
var provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithPopup(provider).then(function(result) {
// This gives you a Google Access Token. You can use it to access the Google API.
var token = result.credential.accessToken;
// 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;
// ...
});
}
</script>
請隨意問任何懷疑,如果你有去通過這個網站For Firebase Google Log in。這個網站已經開發了谷歌登錄firebase,看看他們是如何使用它。希望這可以幫助。
感謝提示,從https://github.com/firebase/firebaseui-web/blob/master/image/獲取了徽標google.svg並將其嵌入按鈕 – gonephishing
沒有提及,我很高興我的回答對你有所幫助。 – MuruGan
如果您不打算使用firebase-ui,那麼您可以自行構建UI。您是否遇到特定問題? –
我想按照Google的品牌指南構建登錄按鈕。那麼看看如何嵌入它可能是通過從一些谷歌CDN獲取圖像。或者除非firebase web js SDK公開了一些方法來生成可以完全解決品牌問題的按鈕 – gonephishing