Merge pull request #491 from beaufortfrancois/master
Don't use Google+ API anymore
This commit is contained in:
Коммит
3e05590eb4
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
var googlePlusUserLoader = (function() {
|
||||
var googleProfileUserLoader = (function() {
|
||||
|
||||
var STATE_START=1;
|
||||
var STATE_ACQUIRING_AUTHTOKEN=2;
|
||||
|
@ -81,7 +81,7 @@ var googlePlusUserLoader = (function() {
|
|||
|
||||
function getUserInfo(interactive) {
|
||||
xhrWithAuth('GET',
|
||||
'https://www.googleapis.com/plus/v1/people/me',
|
||||
'https://www.googleapis.com/oauth2/v1/userinfo',
|
||||
interactive,
|
||||
onUserInfoFetched);
|
||||
}
|
||||
|
@ -102,14 +102,14 @@ var googlePlusUserLoader = (function() {
|
|||
}
|
||||
|
||||
function populateUserInfo(user_info) {
|
||||
user_info_div.innerHTML = "Hello " + user_info.displayName;
|
||||
user_info_div.innerHTML = "Hello " + user_info.name;
|
||||
fetchImageBytes(user_info);
|
||||
}
|
||||
|
||||
function fetchImageBytes(user_info) {
|
||||
if (!user_info || !user_info.image || !user_info.image.url) return;
|
||||
if (!user_info || !user_info.picture) return;
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', user_info.image.url, true);
|
||||
xhr.open('GET', user_info.picture, true);
|
||||
xhr.responseType = 'blob';
|
||||
xhr.onload = onImageFetched;
|
||||
xhr.send();
|
||||
|
@ -118,10 +118,11 @@ var googlePlusUserLoader = (function() {
|
|||
function onImageFetched(e) {
|
||||
if (this.status != 200) return;
|
||||
var imgElem = document.createElement('img');
|
||||
var objUrl = window.webkitURL.createObjectURL(this.response);
|
||||
var objUrl = window.URL.createObjectURL(this.response);
|
||||
imgElem.src = objUrl;
|
||||
imgElem.style.width = '24px';
|
||||
imgElem.onload = function() {
|
||||
window.webkitURL.revokeObjectURL(objUrl);
|
||||
window.URL.revokeObjectURL(objUrl);
|
||||
}
|
||||
user_info_div.insertAdjacentElement("afterbegin", imgElem);
|
||||
}
|
||||
|
@ -212,5 +213,5 @@ var googlePlusUserLoader = (function() {
|
|||
|
||||
})();
|
||||
|
||||
window.onload = googlePlusUserLoader.onload;
|
||||
window.onload = googleProfileUserLoader.onload;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "Identity API Sample",
|
||||
"version": "3.1.2",
|
||||
"version": "3.2",
|
||||
"manifest_version": 2,
|
||||
"minimum_chrome_version": "29",
|
||||
"key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCDJB6ZGcGxtlr/34s+TKgi84QiP7DMekqOjSUS2ubmbhchlM6CN9gYdGQ1aBI3TBXG3YaAu+XyutFA8M8NLLWc4OOGByWaGV11DP6p67g8a+Ids/gX6cNSRnRHiDZXAd44ATxoN4OZjZJk9iQ26RIUjwX07bzntlI+frwwKCk4WQIDAQAB",
|
||||
|
@ -11,9 +11,9 @@
|
|||
},
|
||||
"permissions": ["identity", "https://accounts.google.com/*", "https://www.googleapis.com/*"],
|
||||
"oauth2": {
|
||||
// client_id below is specifc to the application key. Follow the
|
||||
// client_id below is specific to the application key. Follow the
|
||||
// documentation to obtain one for your app.
|
||||
"client_id": "497291774654.apps.googleusercontent.com",
|
||||
"scopes": ["https://www.googleapis.com/auth/plus.login"]
|
||||
"scopes": ["https://www.googleapis.com/auth/userinfo.profile"]
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче