A small wrapper for integrating HelloJs to Vuejs.
HelloJs is a simple and easy to use library for implementing Social Login in web app.
npm install --save hellojs vue-hellojs
or
yarn add hellojs vue-hellojs
And in your entry file:
import Vue from 'vue';
const HelloJs = require('hellojs/dist/hello.all.min.js');
const VueHello = require('vue-hellojs');
HelloJs.init({
google: GOOGLE_APP_CLIENT_ID,
facebook: FACEBOOK_APP_CLIENT_ID
}, {
redirect_uri: 'authcallback/'
});
Vue.use(VueHello, HelloJs);
This wrapper bind hello
to Vue
or this
if you're using single file component.
You can hello
like this:
Vue.hello('google').login()
this.hello('google').login()
In a .vue component file
<template>
<div>
<button @click="auth('google')">Google</button>
</div>
</template>
<script>
export default {
data() {
return {
}
}, methods: {
auth(network) {
const hello = this.hello;
hello(network).login().then(() => {
const authRes = hello(network).getAuthResponse();
/*
performs operations using the token from authRes
*/
hello(network).api('me').then(function (json) {
const profile = json;
/*
performs operations using the user info from profile
*/
});
})
}
}
}
</script>
<style scoped></style>