Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

36
LINES

< > BotCompany Repo | #1013824 // googleSignIn_signInButton

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (34L/1K).

sS googleSignIn_signInButton(S verifyURL) {
  ret googleSignIn_signInButton(verifyURL, "", "");
}

sS googleSignIn_signInButton(S verifyURL, S onSuccess, S onSignOut) {
  ret [[<div class="g-signin2" data-onsuccess="onSignIn"></div>
    <script>
    function onSignIn(googleUser) {
      console.log("Signing in");
      var profile = googleUser.getBasicProfile();
      var email = profile.getEmail();
      if (email != "") {
        var token = googleUser.getAuthResponse().id_token;
        console.log("Email: " + email + "\nToken: " + token);
        var myKeyVals = { token: token };
        $.ajax({
          type: "POST",
          url: "$VERIFYURL",
          data: myKeyVals,
          dataType: "text",
          success: function(data) {
            $ONSUCCESS
          }
        });
      }
    }

    function signOut() {
      var auth2 = gapi.auth2.getAuthInstance();
      auth2.signOut().then(function () { $ONSIGNOUT});
    }
    </script>
  ]].replace("$VERIFYURL", verifyURL)
    .replace("$ONSUCCESS", onSuccess)
    .replace("$ONSIGNOUT", onSignOut);
}

Author comment

Began life as a copy of #1013823

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1013824
Snippet name: googleSignIn_signInButton
Eternal ID of this version: #1013824/9
Text MD5: 8e00fd0620e3e786eff290880eeb828b
Transpilation MD5: d2e52a97285eb9ad11ba99279a751493
Author: stefan
Category: javax / web
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-14 13:08:54
Source code size: 1113 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 359 / 445
Version history: 8 change(s)
Referenced in: [show references]