diff options
author | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2015-10-13 21:28:48 -0400 |
---|---|---|
committer | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2015-10-13 21:28:48 -0400 |
commit | 7adcf4073b1e42a7a2a7baf2a0ffb14d76bdc660 (patch) | |
tree | 2b64b4df05f23d77d22b44bb7a9425dbc06a2f2a /web | |
parent | c32fae261c0991d7a1a4f81cfd28f736f812689e (diff) |
Authenticatiof of all API methods.
Diffstat (limited to 'web')
-rw-r--r-- | web/index.html | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/web/index.html b/web/index.html index a17562e..3655b59 100644 --- a/web/index.html +++ b/web/index.html @@ -12,6 +12,8 @@ <link rel="stylesheet" href="style.css"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script> <script> + var authentication_token = null; + function addPending(albumName) { function makeElement(name) { return $('<li>' + name + ' (<a href="javascript:void(0)">edit</a>)</li>'); @@ -45,6 +47,7 @@ function fetchAlbums() { $.ajax({ url: "/api/albums", + headers: {'X-Token': authentication_token}, success: function(data) { $('#pending-error').empty(); $('#pending-container').empty(); @@ -80,6 +83,7 @@ }; $.ajax({ url: '/api/rename', + headers: {'X-Token': authentication_token}, type: 'POST', contentType: 'application/json', data: JSON.stringify(request), @@ -100,21 +104,12 @@ console.log("Name: " + profile.getName()); console.log("Image URL: " + profile.getImageUrl()); console.log("Email: " + profile.getEmail()); - + authentication_token = googleUser.getAuthResponse().id_token; // The ID token you need to pass to your backend: var id_token = googleUser.getAuthResponse().id_token; console.log("ID Token: " + id_token); $('.g-signin2').remove(); - $.ajax({ - url: '/api/test', - headers: {'X-Token': id_token}, - success: function(data) { - console.log('Success:', data); - }, - error: function(data) { - console.log('Failure:', data); - } - }); + fetchAlbums(); }; </script> </head> |