Libraryless. Click here for Pure Java version (34L/1K).
1 | sS googleSignIn_signInButton(S verifyURL) { |
2 | ret googleSignIn_signInButton(verifyURL, "", ""); |
3 | } |
4 | |
5 | sS googleSignIn_signInButton(S verifyURL, S onSuccess, S onSignOut) { |
6 | ret [[<div class="g-signin2" data-onsuccess="onSignIn"></div> |
7 | <script> |
8 | function onSignIn(googleUser) { |
9 | console.log("Signing in"); |
10 | var profile = googleUser.getBasicProfile(); |
11 | var email = profile.getEmail(); |
12 | if (email != "") { |
13 | var token = googleUser.getAuthResponse().id_token; |
14 | console.log("Email: " + email + "\nToken: " + token); |
15 | var myKeyVals = { token: token }; |
16 | $.ajax({ |
17 | type: "POST", |
18 | url: "$VERIFYURL", |
19 | data: myKeyVals, |
20 | dataType: "text", |
21 | success: function(data) { |
22 | $ONSUCCESS |
23 | } |
24 | }); |
25 | } |
26 | } |
27 | |
28 | function signOut() { |
29 | var auth2 = gapi.auth2.getAuthInstance(); |
30 | auth2.signOut().then(function () { $ONSIGNOUT}); |
31 | } |
32 | </script> |
33 | ]].replace("$VERIFYURL", verifyURL) |
34 | .replace("$ONSUCCESS", onSuccess) |
35 | .replace("$ONSIGNOUT", onSignOut); |
36 | } |
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: | 360 / 447 |
Version history: | 8 change(s) |
Referenced in: | [show references] |