Parcourir la source

add google logout

thomas il y a 3 ans
Parent
commit
2ccbe350d0
3 fichiers modifiés avec 36 ajouts et 3 suppressions
  1. 2 2
      public/login.html
  2. 32 0
      public/logout.html
  3. 2 1
      src/components/GoogleLogin.vue

+ 2 - 2
public/accessdata.html → public/login.html

@@ -5,7 +5,7 @@
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
     <meta name="viewport" content="width=device-width,initial-scale=1.0">
     <meta name="google-signin-client_id" content="398214166622-jkme0i3k4tbsgqh19aejaqatrark5l94.apps.googleusercontent.com">
-    <title>GetAccess Data</title>
+    <title>Login google</title>
   </head>
   <body>
     <h1>Get Google Token</h1>
@@ -36,7 +36,7 @@
 
     <script src="https://apis.google.com/js/platform.js?onload=renderButton" async defer></script>
     <script>
-      const code = (new URLSearchParams(window.location.search)).get('code')
+
       console.log({code})
     </script>
 

+ 32 - 0
public/logout.html

@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html lang="">
+  <head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width,initial-scale=1.0">
+    <meta name="google-signin-client_id" content="398214166622-jkme0i3k4tbsgqh19aejaqatrark5l94.apps.googleusercontent.com">
+    <title>Clear google Login</title>
+  </head>
+  <body>
+    <h1>Clear Google Token</h1>
+    <button onclick="Logout()">Logout</button>
+    <script>
+      function Logout() {
+        console.log('onSuccess');
+        var auth2 = gapi.auth2.getAuthInstance();
+        auth2.signOut().then(function () {
+          window.location.href = '/'
+        });
+      }
+  
+    function onLoad() {
+      gapi.load('auth2', function() {
+        gapi.auth2.init();
+      });
+    }
+    </script>
+
+    <script src="https://apis.google.com/js/platform.js?onload=onLoad" async defer></script>
+
+  </body>
+</html>

+ 2 - 1
src/components/GoogleLogin.vue

@@ -2,7 +2,8 @@
   <div>
       <h3>Google IdToken</h3>
       <button :disabled="loginDisabled()" @click="loginUsingIdToken">Login</button>
-      <a style="margin: 0em 1em; " href="accessdata.html">GET</a>
+      <a style="margin: 0em 1em; " href="login.html">GET</a>
+      <a style="margin: 0em 1em; " href="logout.html">CLEAR</a>
       <div v-if="idToken" style="overflow: hidden; font-size: xx-small; margin: 1em 0em; ">{{ idToken }}</div>
   </div>
 </template>