js-google-auth-lib
v1.0.5
Published
This is JS minimalistic library for google sign in using Google Identity Server
Downloads
9
Maintainers
Readme
##js-google-ath-lib## As google sign in library for any js project which is build on nodejs.
Installation
Install my-project with npm
npm install js-google-auth-lib
Usage/Examples
// Javascript
<!doctype html>
<html>
....
<body>
<div id="signinDiv"></div>
<script type="module">
import GoogleAuth from 'js-google-ath-lib'
const onSuccess = (credentials)=>{
console.log(credentials)
}
const onError = (error)=>{
console.error(error)
}
const getProfileInfo = (profileInfo)=>{
console.log(profileInfo)
}
const googleSignIn = new GoogleAuth({
client_id:'YOUR_CLIENT_ID',
onSuccess,
onError,
getProfileInfo,
})
</body>
</script>
</html>
// ReactJs 16+
import React, {useEffect} from 'react'
import GoogleAuth from 'js-google-ath-lib'
const onSuccess = (credentials)=>{
console.log(credentials)
}
const onError = (error)=>{
console.error(error)
}
const getProfileInfo = (profileInfo)=>{
console.log(profileInfo)
}
useEffect(()=>{
const googleSignIn = new GoogleAuth({
client_id:'YOUR_CLIENT_ID',
onSuccess,
onError,
getProfileInfo,
})
},[])
const App = ()=>{
return <div id="signinDiv"></div>
}
export default App
// Vuejs 3+
<script setup>
import { onMounted } from "vue";
import GoogleAuth from "js-google-auth-lib";
const onSuccess = (credentials)=>{
console.log(credentials)
}
const onError = (error)=>{
console.error(error)
}
const getProfileInfo = (profileInfo)=>{
console.log(profileInfo)
}
onMounted(() => {
const googleAuth = new GoogleAuth({
client_id:"YOUR_CLIENT_ID",
onSuccess,
onError,
getProfileInfo,
});
});
</script>
<template>
<div id="signinDiv"></div>
</template>