- basic login button on website frontend - index.html hosting using python - posting google oauth token from javascript on client side - passing token id to python hoster - verifying token, and returning a string to client
		
			
				
	
	
		
			52 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
 | 
						|
<meta content="utf-8" http-equiv="encoding">
 | 
						|
 | 
						|
<html lang="en" itemscope itemtype="http://schema.org/Article">
 | 
						|
  <head>
 | 
						|
 | 
						|
  <!-- BEGIN Pre-requisites -->
 | 
						|
  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js">
 | 
						|
  </script>
 | 
						|
  <script src="https://apis.google.com/js/client:platform.js?onload=start" async defer>
 | 
						|
  </script>
 | 
						|
  <!-- END Pre-requisites -->
 | 
						|
 | 
						|
    <meta name="google-signin-scope" content="profile email">
 | 
						|
    <meta name="google-signin-client_id" 
 | 
						|
    content="377787187748-shuvi4iq5bi4gdet6q3ioataimobs4lh.apps.googleusercontent.com">
 | 
						|
    <script src="https://apis.google.com/js/platform.js" async defer></script>
 | 
						|
 | 
						|
  </head>
 | 
						|
  <body>
 | 
						|
 | 
						|
    <div class="g-signin2" data-onsuccess="onSignIn" data-theme="dark"></div>
 | 
						|
    <script>
 | 
						|
      function onSignIn(googleUser) {
 | 
						|
        // Useful data for your client-side scripts:
 | 
						|
        var profile = googleUser.getBasicProfile();
 | 
						|
        console.log("ID: " + profile.getId()); // Don't send this directly to your server!
 | 
						|
        console.log('Full Name: ' + profile.getName());
 | 
						|
        console.log('Given Name: ' + profile.getGivenName());
 | 
						|
        console.log('Family Name: ' + profile.getFamilyName());
 | 
						|
        console.log("Image URL: " + profile.getImageUrl());
 | 
						|
        console.log("Email: " + profile.getEmail());
 | 
						|
 | 
						|
        // The ID token you need to pass to your backend:
 | 
						|
        var id_token = googleUser.getAuthResponse().id_token;
 | 
						|
        console.log("ID Token: " + id_token);
 | 
						|
 | 
						|
 | 
						|
        // Send the code to the server
 | 
						|
        var xhr = new XMLHttpRequest();
 | 
						|
        xhr.open('POST', 'http://192.168.68.103.xip.io:1234/website.py');
 | 
						|
        xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
 | 
						|
        xhr.onload = function() {
 | 
						|
          console.log('Signed in as: ' + xhr.responseText);
 | 
						|
        };
 | 
						|
        xhr.send(id_token);
 | 
						|
        }
 | 
						|
    </script>
 | 
						|
 | 
						|
  </body>
 | 
						|
</html>
 |