Skip to main content

How To Login With Google Using Javascript






Hello friends ajj me apko btaunga ki kis parkar ham javascript ka use karke  google login kar sakte hai.



Steps1- create a javascript file love.js



love.js



    function Success() {



  

        gapi.client.load('plus', 'v1', function () {

            var request = gapi.client.plus.people.get({'userId': 'me'});

            //for display user detail

            request.execute(function (resp) {

                var profileHTML = '<a href="javascript:void(0);" onclick="signOut();"><h3>Sign out</h3></a>';

              
  profileHTML += ''+resp.emails[0].value+'';

$('.userContent').html(profileHTML);

                 alert("welcome here You are Login with Javascript!");

            });

        });

    }



 

//this is for rendering after success

    function renderButton() {

        gapi.signin2.render('gSignIn', {'onsuccess': Success});

    }





//this function is used for signout

    function signOut() {







        var auth2 = gapi.auth2.getAuthInstance();

        auth2.signOut().then(function () {

            $('.userContent').html('<font color="red">You are Logged Out Successfully</font>');

            alert("your are redirect to logout if u want logout then click on ok!");

        });





    }















Step2- create a login.html file



Login.html



<!DOCTYPE html>

<html lang="en">

<head>

<script src="jquery.min.js"></script>

<meta name="google-signin-client_id" content="
690553206748-snb29kb4s9rfnejbrgv0nfjfmbd805lq.apps.googleusercontent.com">

<script src="love.js"></script>

<script src="https://apis.google.com/js/client:platform.js?onload=renderButton" async defer></script>



</head>

<body>



<div id="gSignIn"></div>



<div class="userContent"></div>





</body>

</html>



Yanha apko sirf



<meta name="google-signin-client_id" content="690553206748-snb29kb4s9rfnejbrgv0nfjfmbd805lq.apps.googleusercontent.com">



Me  apke dwara create kiye gye google app ki client id enter karke code save kar dena hai

Is parkar aap easily 2 minutes me login with google (javascript) ka option apne website me add kar sakte ho.





Aap image,gendr etc be display karwa sakte ho niche diye gye code ka use kerke-





profileHTML += '<img src="'+resp.image.url+'"/><div class="proDetails"><p>'+resp.displayName+'</p><p>'+resp.emails[0].value+'</p><p>'+resp.gender+'</p><p>'+resp.id+'</p><p><a href="'+resp.url+'">View Google+ Profile</a></p></div></div>';

aap code me diye gye profileHTML ka code remove karke upper diya gya code wanha paste kar de .esa karke aap user ki other information,email,name,gender,id etc display karwa sakte ho ,

agar apko koi problem a rhe hai to aap comment me puch sakte ho.





Thank You

Team Gajabwap Web In Hindi



Comments

Popular posts from this blog

How to Download Vimeo Thumbnail With PHP

Vimeo Thumbnail Downloader Tool – Vimeo Video Ka Thumbnail Download Karein Aaj ke is tutorial mein hum Vimeo Thumbnail Downloader Tool ke baare mein jaanenge. Is tool ki help se hum Vimeo video URL se us video ki thumbnail image obtain kar sakte hain. Agar aap PHP, Web Development, HTML, CSS aur Online Tools banana seekh rahe hain, to ye ek useful PHP project example hai. Vimeo Thumbnail Downloader Kya Hai? Vimeo Thumbnail Downloader ek simple tool hai jisme user Vimeo video ka URL enter karta hai. Tool Vimeo video ID ko identify karta hai aur available thumbnail image ko display karta hai. Example Vimeo URL: https://vimeo.com/389063954 Is URL mein: 389063954 Vimeo video ID hai. Vimeo Thumbnail Downloader Kaise Work Karta Hai? Is PHP script mein mainly do functions use kiye gaye hain: 1. getVimeoId() Ye function Vimeo URL se video ID find karta hai. 2. getVimeoThumb() Ye function Vimeo video ID ke basis par thumbnail information retrieve karta hai aur available thumbnail...

How To Create Contact Form With Validation-Php & Html

How To Create Contact Form - Hello Friends Ajj Me Apko Btaunga   Ki Kis Prakar   Ham Apni Website Ke Liye Contact Form Bnana Sakta Hai.( By Using   Php Contact Form With Validation Script ) Contact Form Hmare Website Ke Liye Bhut He Jrruri Hota Hai.Contact Form Ke Help Se He User Apna Message Website Owner(Admin) Ko Bhej Sakte Hai. Ajj Me Apko Btane Wala Hu Ki Kis Parkar Ham Contact Form Banakar Apne Website Me Add Kar Sakte Hai Or Apni Website Ke Liye Contact Form Bana Sakte Hai Is Contact Form Me   Ham Php Mail Function() Ka Use Karege . Ab Jab Be Koi User Contact Form Me Apni Information ,Message Details Fill Karke Submit Karega To Uski Sare Information Website Admin Ke Email Id Par A Jaiyegi Jo Be Admin Dwara   Niche Diye Gye Code Me Setup Ki Hogi. Used Language- ·          HTML ·          Jquery ·          Php ...

How To Send Sms From Website Using Php-Textlocal SMS

Hello Friends Ajj Me Apko Btaunga Ki Kis Prakar Aap Apni Website Me Free Sms Send Ka Option Integrate Kar Sakte Ho. Bulk sms in India-Best company Iske Liye Apko Sabse Pehle   Https://Www.Textlocal.In/Signup Par Signup Karke Account Create Karna Hai.Ye Ek Achi bulk sms provider company hai ·          Account Create Hone Ke Bad Aap Apna Username And Password Enter Karke Apne Dashboard Me Login Ho Jaiye( textlocal login) ·          Yanha Apko Text Local Company Dwara 10 Meassge Free Testing Ke Liye Diye Jayege ·          Aap Sms Plan Buy Kar Sakte Ho Is Company Dwara Bhut He Kam Prize Me Sms Pakage,plan provide  Kiye Jate Hai Textlocal Price Plans –  index.php <?php if(isset($_POST['code']) &&  isset($_POST['mobile'])){ // Authorisation details. $username = "enter your textlocal account email id here"; $hash = "...