diff options
author | William Carroll <wpcarro@gmail.com> | 2020-08-06T21·21+0100 |
---|---|---|
committer | William Carroll <wpcarro@gmail.com> | 2020-08-06T21·23+0100 |
commit | a7ddb56b9bdca9773d6d0b71ffa128cd64c9485e (patch) | |
tree | 07e799b99b9f9a72e247e1133acf835aed641d3a /website/sandbox/learnpianochords/src/server/index.html | |
parent | 1fc1087014a235a4fd153ea239ec3e5509757c17 (diff) |
Support echo server to test POST /verify
TL;DR: - Add common dependencies like Servant, Aeson, Warp, Cors - Define a POST /verify endpoint for our client to hit - POST to /verify client-side onSignIn
Diffstat (limited to 'website/sandbox/learnpianochords/src/server/index.html')
-rw-r--r-- | website/sandbox/learnpianochords/src/server/index.html | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/website/sandbox/learnpianochords/src/server/index.html b/website/sandbox/learnpianochords/src/server/index.html index ce80faf0d501..459a5c8c8250 100644 --- a/website/sandbox/learnpianochords/src/server/index.html +++ b/website/sandbox/learnpianochords/src/server/index.html @@ -11,11 +11,18 @@ <a href="#" onclick="signOut();">Sign out</a> <script> function onSignIn(googleUser) { - var profile = googleUser.getBasicProfile(); - console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead. - console.log('Name: ' + profile.getName()); - console.log('Image URL: ' + profile.getImageUrl()); - console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present. + var idToken = googleUser.getAuthResponse().id_token; + fetch('http://localhost:3000/verify', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + idToken: idToken, + }) + }) + .then(x => console.log(x)) + .catch(err => console.error(err)); } function signOut() { var auth2 = gapi.auth2.getAuthInstance(); |