{"action":"created","comment":{"url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/pulls/comments/26511814","id":26511814,"diff_hunk":"@@ -0,0 +1,103 @@\n+GoogleSocialProvider = function(dispatchEvent) {\n+  console.log('GoogleSocialProvider called');\n+  this.dispatchEvent_ = dispatchEvent;\n+  this.networkName_ = 'google';\n+  this.initState_();\n+};\n+GoogleSocialProvider.prototype = new FirebaseSocialProvider();\n+\n+GoogleSocialProvider.prototype.getOAuthToken_ = function() {\n+  var OAUTH_REDIRECT_URLS = [\n+    \"https://fmdppkkepalnkeommjadgbhiohihdhii.chromiumapp.org/\",\n+    \"https://www.uproxy.org/oauth-redirect-uri\",\n+    \"http://freedomjs.org/\",\n+    'http://localhost:8080/'\n+  ];\n+  var OAUTH_CLIENT_ID = '746567772449-jkm5q5hjqtpq5m9htg9kn0os8qphra4d.apps.googleusercontent.com';\n+  var OAUTH_SCOPE = 'https://www.googleapis.com/auth/plus.login%20https://www.googleapis.com/auth/plus.me%20https://www.googleapis.com/auth/userinfo.email%20https://www.googleapis.com/auth/userinfo.profile';\n+\n+  var oauth = freedom[\"core.oauth\"]();\n+  return oauth.initiateOAuth(OAUTH_REDIRECT_URLS).then(function(stateObj) {\n+    var oauthUrl = \"https://accounts.google.com/o/oauth2/auth?\" +\n+        \"client_id=\" + OAUTH_CLIENT_ID +\n+        \"&scope=\" + OAUTH_SCOPE +\n+        \"&redirect_uri=\" + encodeURIComponent(stateObj.redirect) +\n+        \"&state=\" + encodeURIComponent(stateObj.state) +\n+        \"&response_type=token\";\n+    var url = 'https://accounts.google.com/accountchooser?continue=' +\n+        encodeURIComponent(oauthUrl);\n+    return oauth.launchAuthFlow(url, stateObj);\n+  }).then(function(responseUrl) {\n+    return responseUrl.match(/access_token=([^&]+)/)[1];\n+  }).catch(function (err) {\n+    return Promise.reject('Login error: ' + err.message);\n+  });\n+};\n+\n+GoogleSocialProvider.prototype.loadUsers_ = function() {\n+  // TODO: should we periodically check for new friends?  Or just force\n+  // users to logout then login again to detect new friends?\n+  this.googleGet_('plus/v1/people/me/people/visible').then(function(resp) {\n+    console.log('got my contacts, ' + JSON.stringify(resp));\n+    for (var i = 0; i < resp.items.length; ++i) {\n+      var friend = resp.items[i];\n+      this.addUserProfile_({\n+        userId: friend.id,\n+        name: friend.displayName,\n+        imageData: friend.image.url,\n+        url: friend.url\n+      });\n+    }\n+  }.bind(this)).catch(function(e) {\n+    console.error('Error loading Google users', e);\n+  });\n+};\n+\n+\n+GoogleSocialProvider.prototype.getMyUserProfile_ = function() {\n+  if (!this.loginState_) {\n+    throw 'Error in GoogleSocialProvider.getMyUserProfile_: not logged in';\n+  }\n+  var cachedUserProfile =\n+      this.loginState_.authData[this.networkName_].cachedUserProfile;\n+  return {\n+    userId: this.getUserId_(),\n+    name: cachedUserProfile.name,\n+    lastUpdated: Date.now(),\n+    url: cachedUserProfile.link,\n+    imageData: cachedUserProfile.picture + '?sz=50'\n+  };\n+};\n+\n+\n+GoogleSocialProvider.prototype.googleGet_ = function(endPoint) {\n+  if (!this.loginState_) {\n+    throw 'Not signed in';\n+  }\n+  var xhr = new XMLHttpRequest();\n+  // TODO: is it safe to include the API KEY?","path":"src/google-social-provider.js","position":78,"original_position":78,"commit_id":"fa0bc026e39fae981325565b59441121e0d2ca27","original_commit_id":"fa0bc026e39fae981325565b59441121e0d2ca27","user":{"login":"soycode","id":587921,"avatar_url":"https://avatars.githubusercontent.com/u/587921?v=3","gravatar_id":"","url":"https://api.github.com/users/soycode","html_url":"https://github.com/soycode","followers_url":"https://api.github.com/users/soycode/followers","following_url":"https://api.github.com/users/soycode/following{/other_user}","gists_url":"https://api.github.com/users/soycode/gists{/gist_id}","starred_url":"https://api.github.com/users/soycode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soycode/subscriptions","organizations_url":"https://api.github.com/users/soycode/orgs","repos_url":"https://api.github.com/users/soycode/repos","events_url":"https://api.github.com/users/soycode/events{/privacy}","received_events_url":"https://api.github.com/users/soycode/received_events","type":"User","site_admin":false},"body":"I think it's worth resolving this TODO for this pull request, as well as double-checking similar things for e.g. OAUTH_CLIENT_ID and some of the other hardcoded values/urls.","created_at":"2015-03-16T18:11:48Z","updated_at":"2015-03-16T18:11:48Z","html_url":"https://github.com/freedomjs/freedom-social-firebase/pull/6#discussion_r26511814","pull_request_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/freedomjs/freedom-social-firebase/pulls/comments/26511814"},"html":{"href":"https://github.com/freedomjs/freedom-social-firebase/pull/6#discussion_r26511814"},"pull_request":{"href":"https://api.github.com/repos/freedomjs/freedom-social-firebase/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/pulls/6","id":31186955,"html_url":"https://github.com/freedomjs/freedom-social-firebase/pull/6","diff_url":"https://github.com/freedomjs/freedom-social-firebase/pull/6.diff","patch_url":"https://github.com/freedomjs/freedom-social-firebase/pull/6.patch","issue_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/issues/6","number":6,"state":"open","locked":false,"title":"Firebase social provider, including Facebook and Google+ implementations","user":{"login":"dborkan","id":6494307,"avatar_url":"https://avatars.githubusercontent.com/u/6494307?v=3","gravatar_id":"","url":"https://api.github.com/users/dborkan","html_url":"https://github.com/dborkan","followers_url":"https://api.github.com/users/dborkan/followers","following_url":"https://api.github.com/users/dborkan/following{/other_user}","gists_url":"https://api.github.com/users/dborkan/gists{/gist_id}","starred_url":"https://api.github.com/users/dborkan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dborkan/subscriptions","organizations_url":"https://api.github.com/users/dborkan/orgs","repos_url":"https://api.github.com/users/dborkan/repos","events_url":"https://api.github.com/users/dborkan/events{/privacy}","received_events_url":"https://api.github.com/users/dborkan/received_events","type":"User","site_admin":false},"body":"Firebase social provider, including Facebook and Google+ implementations.\r\n\r\nStructure:\r\n* freedom-social-firebase.js provides an abstract FirebaseSocialProvider class, which implements the Freedom Social API.  This class is responsible for:\r\n * Emitting onUserProfile, onClientState, and onMessage events to users\r\n * Implementing login and logout\r\n * sending messages to clients\r\n* Inheriting classes of FirebaseSocialProvider (FaebookSocialProvider and GoogleSocialProvider) are responsible for:\r\n * Getting an OAuth token for that network\r\n * Getting the user profiles for the logged in user's friends (id, name, image, and url for each friend)\r\n * Getting the user profile for the logged in user (their id, name, image and url)\r\n* Our Firebase app's rules (at https://popping-heat-4874.firebaseio.com/?page=Security) ensure that proper permissions are enforced: users cannot message users who have not listed them as friends, one friend cannot spoof another, users can't read the data of any other user except for the client presence information of users who have listed them as friends.\r\n\r\nTested in social provider demo and in uProxy.","created_at":"2015-03-14T17:38:26Z","updated_at":"2015-03-16T18:11:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9575e47b3020ad3bef559a9ff0f3210a1d4420ba","assignee":{"login":"soycode","id":587921,"avatar_url":"https://avatars.githubusercontent.com/u/587921?v=3","gravatar_id":"","url":"https://api.github.com/users/soycode","html_url":"https://github.com/soycode","followers_url":"https://api.github.com/users/soycode/followers","following_url":"https://api.github.com/users/soycode/following{/other_user}","gists_url":"https://api.github.com/users/soycode/gists{/gist_id}","starred_url":"https://api.github.com/users/soycode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soycode/subscriptions","organizations_url":"https://api.github.com/users/soycode/orgs","repos_url":"https://api.github.com/users/soycode/repos","events_url":"https://api.github.com/users/soycode/events{/privacy}","received_events_url":"https://api.github.com/users/soycode/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/pulls/6/commits","review_comments_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/pulls/6/comments","review_comment_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/pulls/comments{/number}","comments_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/issues/6/comments","statuses_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/statuses/fa0bc026e39fae981325565b59441121e0d2ca27","head":{"label":"freedomjs:dborkan-firebase","ref":"dborkan-firebase","sha":"fa0bc026e39fae981325565b59441121e0d2ca27","user":{"login":"freedomjs","id":5855670,"avatar_url":"https://avatars.githubusercontent.com/u/5855670?v=3","gravatar_id":"","url":"https://api.github.com/users/freedomjs","html_url":"https://github.com/freedomjs","followers_url":"https://api.github.com/users/freedomjs/followers","following_url":"https://api.github.com/users/freedomjs/following{/other_user}","gists_url":"https://api.github.com/users/freedomjs/gists{/gist_id}","starred_url":"https://api.github.com/users/freedomjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freedomjs/subscriptions","organizations_url":"https://api.github.com/users/freedomjs/orgs","repos_url":"https://api.github.com/users/freedomjs/repos","events_url":"https://api.github.com/users/freedomjs/events{/privacy}","received_events_url":"https://api.github.com/users/freedomjs/received_events","type":"Organization","site_admin":false},"repo":{"id":30378484,"name":"freedom-social-firebase","full_name":"freedomjs/freedom-social-firebase","owner":{"login":"freedomjs","id":5855670,"avatar_url":"https://avatars.githubusercontent.com/u/5855670?v=3","gravatar_id":"","url":"https://api.github.com/users/freedomjs","html_url":"https://github.com/freedomjs","followers_url":"https://api.github.com/users/freedomjs/followers","following_url":"https://api.github.com/users/freedomjs/following{/other_user}","gists_url":"https://api.github.com/users/freedomjs/gists{/gist_id}","starred_url":"https://api.github.com/users/freedomjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freedomjs/subscriptions","organizations_url":"https://api.github.com/users/freedomjs/orgs","repos_url":"https://api.github.com/users/freedomjs/repos","events_url":"https://api.github.com/users/freedomjs/events{/privacy}","received_events_url":"https://api.github.com/users/freedomjs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/freedomjs/freedom-social-firebase","description":"Firebase Social Provider","fork":false,"url":"https://api.github.com/repos/freedomjs/freedom-social-firebase","forks_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/forks","keys_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/keys{/key_id}","collaborators_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/teams","hooks_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/hooks","issue_events_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/issues/events{/number}","events_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/events","assignees_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/assignees{/user}","branches_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/branches{/branch}","tags_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/tags","blobs_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/git/refs{/sha}","trees_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/git/trees{/sha}","statuses_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/statuses/{sha}","languages_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/languages","stargazers_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/stargazers","contributors_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/contributors","subscribers_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/subscribers","subscription_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/subscription","commits_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/commits{/sha}","git_commits_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/git/commits{/sha}","comments_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/comments{/number}","issue_comment_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/issues/comments{/number}","contents_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/contents/{+path}","compare_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/compare/{base}...{head}","merges_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/merges","archive_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/downloads","issues_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/issues{/number}","pulls_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/pulls{/number}","milestones_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/milestones{/number}","notifications_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/labels{/name}","releases_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/releases{/id}","created_at":"2015-02-05T21:07:44Z","updated_at":"2015-03-16T16:24:27Z","pushed_at":"2015-03-14T17:46:15Z","git_url":"git://github.com/freedomjs/freedom-social-firebase.git","ssh_url":"git@github.com:freedomjs/freedom-social-firebase.git","clone_url":"https://github.com/freedomjs/freedom-social-firebase.git","svn_url":"https://github.com/freedomjs/freedom-social-firebase","homepage":"","size":476,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":10,"forks":0,"open_issues":10,"watchers":0,"default_branch":"master"}},"base":{"label":"freedomjs:master","ref":"master","sha":"29a8872028480b42e625fa1459f4acaa5781cf1b","user":{"login":"freedomjs","id":5855670,"avatar_url":"https://avatars.githubusercontent.com/u/5855670?v=3","gravatar_id":"","url":"https://api.github.com/users/freedomjs","html_url":"https://github.com/freedomjs","followers_url":"https://api.github.com/users/freedomjs/followers","following_url":"https://api.github.com/users/freedomjs/following{/other_user}","gists_url":"https://api.github.com/users/freedomjs/gists{/gist_id}","starred_url":"https://api.github.com/users/freedomjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freedomjs/subscriptions","organizations_url":"https://api.github.com/users/freedomjs/orgs","repos_url":"https://api.github.com/users/freedomjs/repos","events_url":"https://api.github.com/users/freedomjs/events{/privacy}","received_events_url":"https://api.github.com/users/freedomjs/received_events","type":"Organization","site_admin":false},"repo":{"id":30378484,"name":"freedom-social-firebase","full_name":"freedomjs/freedom-social-firebase","owner":{"login":"freedomjs","id":5855670,"avatar_url":"https://avatars.githubusercontent.com/u/5855670?v=3","gravatar_id":"","url":"https://api.github.com/users/freedomjs","html_url":"https://github.com/freedomjs","followers_url":"https://api.github.com/users/freedomjs/followers","following_url":"https://api.github.com/users/freedomjs/following{/other_user}","gists_url":"https://api.github.com/users/freedomjs/gists{/gist_id}","starred_url":"https://api.github.com/users/freedomjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freedomjs/subscriptions","organizations_url":"https://api.github.com/users/freedomjs/orgs","repos_url":"https://api.github.com/users/freedomjs/repos","events_url":"https://api.github.com/users/freedomjs/events{/privacy}","received_events_url":"https://api.github.com/users/freedomjs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/freedomjs/freedom-social-firebase","description":"Firebase Social Provider","fork":false,"url":"https://api.github.com/repos/freedomjs/freedom-social-firebase","forks_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/forks","keys_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/keys{/key_id}","collaborators_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/teams","hooks_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/hooks","issue_events_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/issues/events{/number}","events_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/events","assignees_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/assignees{/user}","branches_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/branches{/branch}","tags_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/tags","blobs_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/git/refs{/sha}","trees_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/git/trees{/sha}","statuses_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/statuses/{sha}","languages_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/languages","stargazers_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/stargazers","contributors_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/contributors","subscribers_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/subscribers","subscription_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/subscription","commits_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/commits{/sha}","git_commits_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/git/commits{/sha}","comments_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/comments{/number}","issue_comment_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/issues/comments{/number}","contents_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/contents/{+path}","compare_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/compare/{base}...{head}","merges_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/merges","archive_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/downloads","issues_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/issues{/number}","pulls_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/pulls{/number}","milestones_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/milestones{/number}","notifications_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/labels{/name}","releases_url":"https://api.github.com/repos/freedomjs/freedom-social-firebase/releases{/id}","created_at":"2015-02-05T21:07:44Z","updated_at":"2015-03-16T16:24:27Z","pushed_at":"2015-03-14T17:46:15Z","git_url":"git://github.com/freedomjs/freedom-social-firebase.git","ssh_url":"git@github.com:freedomjs/freedom-social-firebase.git","clone_url":"https://github.com/freedomjs/freedom-social-firebase.git","svn_url":"https://github.com/freedomjs/freedom-social-firebase","homepage":"","size":476,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":10,"forks":0,"open_issues":10,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/freedomjs/freedom-social-firebase/pulls/6"},"html":{"href":"https://github.com/freedomjs/freedom-social-firebase/pull/6"},"issue":{"href":"https://api.github.com/repos/freedomjs/freedom-social-firebase/issues/6"},"comments":{"href":"https://api.github.com/repos/freedomjs/freedom-social-firebase/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/freedomjs/freedom-social-firebase/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/freedomjs/freedom-social-firebase/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/freedomjs/freedom-social-firebase/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/freedomjs/freedom-social-firebase/statuses/fa0bc026e39fae981325565b59441121e0d2ca27"}}}}