Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
AJ ONeal | 5db5fcb5e6 | 4 years ago |
AJ ONeal | 0df4535e17 | 5 years ago |
AJ ONeal | 86e605f265 | 5 years ago |
2 changed files with 77 additions and 0 deletions
@ -0,0 +1,60 @@ |
|||
'use strict'; |
|||
|
|||
// https://developers.google.com/sheets/api/guides/authorizing
|
|||
// https://www.googleapis.com/auth/spreadsheets.readonly
|
|||
|
|||
// Scope names
|
|||
// https://developers.google.com/drive/api/v3/about-auth
|
|||
|
|||
// Google Sheets API
|
|||
// https://developers.google.com/sheets/api/guides/migration#list_spreadsheets_for_the_authenticated_user
|
|||
|
|||
function onSignIn(googleUser) { |
|||
var profile = googleUser.getBasicProfile(); |
|||
|
|||
var id_token = googleUser.getAuthResponse().id_token; |
|||
var access_token = googleUser.getAuthResponse(); |
|||
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.
|
|||
console.log('access_token', access_token); |
|||
console.log('id_token', id_token); |
|||
window |
|||
.fetch('https://oauth2.googleapis.com/tokeninfo?id_token=' + id_token) |
|||
.then(function(resp) { |
|||
return resp.json().then(function(data) { |
|||
console.log(data); |
|||
}); |
|||
}); |
|||
/* |
|||
window |
|||
.fetch( |
|||
"https://www.googleapis.com/drive/v3/files?q=mimeType%3D'application%2Fvnd.google-apps.spreadsheet'", |
|||
{ |
|||
headers: {Authorization: 'Bearer ' + access_token.access_token}, |
|||
}, |
|||
) |
|||
.then(function(resp) { |
|||
return resp.json().then(function(data) { |
|||
console.log(data); |
|||
}); |
|||
}); |
|||
window |
|||
.fetch('https://spreadsheets.google.com/feeds/spreadsheets/private/full', { |
|||
headers: {Authorization: 'Bearer ' + access_token.access_token}, |
|||
}) |
|||
.then(function(resp) { |
|||
return resp.json().then(function(data) { |
|||
console.log(data); |
|||
}); |
|||
}); |
|||
*/ |
|||
} |
|||
|
|||
function signOut() { |
|||
var auth2 = gapi.auth2.getAuthInstance(); |
|||
auth2.signOut().then(function() { |
|||
console.log('User signed out.'); |
|||
}); |
|||
} |
Loading…
Reference in new issue