| 35 | |
| 36 | // [START cloudrun_end_user_firebase_sign_in] |
| 37 | function signIn() { |
| 38 | const provider = new firebase.auth.GoogleAuthProvider(); |
| 39 | provider.addScope('https://www.googleapis.com/auth/userinfo.email'); |
| 40 | firebase |
| 41 | .auth() |
| 42 | .signInWithPopup(provider) |
| 43 | .then(result => { |
| 44 | // Returns the signed in user along with the provider's credential |
| 45 | console.log(`${result.user.displayName} logged in.`); |
| 46 | window.alert(`Welcome ${result.user.displayName}!`); |
| 47 | }) |
| 48 | .catch(err => { |
| 49 | console.log(`Error during sign in: ${err.message}`); |
| 50 | window.alert('Sign in failed. Retry or check your browser logs.'); |
| 51 | }); |
| 52 | } |
| 53 | // [END cloudrun_end_user_firebase_sign_in] |
| 54 | |
| 55 | function signOut() { |