逗人, 我正在使用 GOOGLE SCRIPT 和 GOOGLE SPREADSHEET 。
使用GOOGLE SCRIPT构建的 HTML侧边栏我正在尝试使用FIREBASE登录(Google登录)。
以下是打开侧边栏的代码:
var html = HtmlService.createTemplateFromFile( 'menu' )
.evaluate()
.setTitle( 'Amis' )
.setWidth( 500 )
.setSandboxMode( HtmlService.SandboxMode.IFRAME );
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.showSidebar( html );
以下是FIREBASE (Google登录)的代码:
/**
* show a popup with the google login
*/
function loginWithGoogle() {
var provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithPopup( provider ).then( function( result ) {
onLoggedState(result.user);
} ).catch( function( error ) {
console.log('ERROR', 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;
// ...
} );
}
适用于Chrome,Edge,Firefox ,但不适用于互联网探索11 。
这里有例外:
error.code "auth/operation-not-supported-in-this-environment"
error.message "This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled."