Skip to content

Instantly share code, notes, and snippets.

@standinga
Created November 20, 2019 04:33
Show Gist options
  • Save standinga/945148af7846a3d66431ab8527bb729f to your computer and use it in GitHub Desktop.
Save standinga/945148af7846a3d66431ab8527bb729f to your computer and use it in GitHub Desktop.
final update to index.vue for medium post about authenticating with google sign in and firebase
<template>
<div class="container">
<button @click="signInRedirect">Sign With Redirect</button>
<button @click="signInPopup">Sign With Pop Up</button>
<button @click="test">Test</button>
</div>
</template>
<script>
export default {
methods: {
signInRedirect: async function() {
var provider = new this.$firebase.auth.GoogleAuthProvider()
const redr = await this.$firebase.auth().signInWithRedirect(provider)
},
signInPopup: async function() {
var provider = new this.$firebase.auth.GoogleAuthProvider()
const result = await this.$firebase.auth().signInWithPopup(provider)
var user = result.user
console.log(user)
},
test: async function() {
const user = this.$firebase.auth().currentUser
const idToken = await user.getIdToken(true)
const url = `https://sign-9aee2.firebaseio.com/test.json?auth=${idToken}`
const test = await this.$axios.$get(url)
console.log(test)
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment