{"action":"created","issue":{"url":"https://api.github.com/repos/meteor/meteor/issues/7550","repository_url":"https://api.github.com/repos/meteor/meteor","labels_url":"https://api.github.com/repos/meteor/meteor/issues/7550/labels{/name}","comments_url":"https://api.github.com/repos/meteor/meteor/issues/7550/comments","events_url":"https://api.github.com/repos/meteor/meteor/issues/7550/events","html_url":"https://github.com/meteor/meteor/pull/7550","id":168934904,"number":7550,"title":"Expose the function that gets fb data from an access token","user":{"login":"gsabran","id":4228246,"avatar_url":"https://avatars.githubusercontent.com/u/4228246?v=3","gravatar_id":"","url":"https://api.github.com/users/gsabran","html_url":"https://github.com/gsabran","followers_url":"https://api.github.com/users/gsabran/followers","following_url":"https://api.github.com/users/gsabran/following{/other_user}","gists_url":"https://api.github.com/users/gsabran/gists{/gist_id}","starred_url":"https://api.github.com/users/gsabran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gsabran/subscriptions","organizations_url":"https://api.github.com/users/gsabran/orgs","repos_url":"https://api.github.com/users/gsabran/repos","events_url":"https://api.github.com/users/gsabran/events{/privacy}","received_events_url":"https://api.github.com/users/gsabran/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-08-02T16:52:35Z","updated_at":"2016-08-04T00:37:04Z","closed_at":"2016-08-02T23:00:33Z","pull_request":{"url":"https://api.github.com/repos/meteor/meteor/pulls/7550","html_url":"https://github.com/meteor/meteor/pull/7550","diff_url":"https://github.com/meteor/meteor/pull/7550.diff","patch_url":"https://github.com/meteor/meteor/pull/7550.patch"},"body":"It's possible to get an access token directly, for instance with mobile application. To make it easier to handle those access tokens on the backend, I split the function that handles the token from the larger function that starts with the code.\r\n\r\nThis enables things like handling fb login directly from an access token:\r\n\r\n```js\r\nlet fbAppId = null;\r\nexport const loginWithFacebook = (params, req, res) => {\r\n  const fbAccessToken = req.body.token;\r\n\r\n  // make sure the access token is for our app\r\n  const fbAppIdForToken = JSON.parse(HTTP.get(\r\n    \"https://graph.facebook.com/app\", {\r\n      params: { access_token: fbAccessToken }\r\n    }).content).id;\r\n  // get our app id\r\n  if (!fbAppId) {\r\n    const config = ServiceConfiguration.configurations.findOne({service: 'facebook'});\r\n    fbAppId = config.appId;\r\n  }\r\n  if (fbAppId !== fbAppIdForToken) {\r\n    // handle incorrect token\r\n    return;\r\n  }\r\n\r\n  const expiresAt = req.body.expiresAt;\r\n  const authResult = Facebook.handleAuthFromAccessToken(fbAccessToken, expiresAt);\r\n\r\n  const { userId } = Accounts.updateOrCreateUserFromExternalService(\r\n    'facebook',\r\n    authResult.serviceData,\r\n    authResult.options\r\n  );\r\n  ...\r\n};\r\n```"},"comment":{"url":"https://api.github.com/repos/meteor/meteor/issues/comments/237417369","html_url":"https://github.com/meteor/meteor/pull/7550#issuecomment-237417369","issue_url":"https://api.github.com/repos/meteor/meteor/issues/7550","id":237417369,"user":{"login":"gsabran","id":4228246,"avatar_url":"https://avatars.githubusercontent.com/u/4228246?v=3","gravatar_id":"","url":"https://api.github.com/users/gsabran","html_url":"https://github.com/gsabran","followers_url":"https://api.github.com/users/gsabran/followers","following_url":"https://api.github.com/users/gsabran/following{/other_user}","gists_url":"https://api.github.com/users/gsabran/gists{/gist_id}","starred_url":"https://api.github.com/users/gsabran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gsabran/subscriptions","organizations_url":"https://api.github.com/users/gsabran/orgs","repos_url":"https://api.github.com/users/gsabran/repos","events_url":"https://api.github.com/users/gsabran/events{/privacy}","received_events_url":"https://api.github.com/users/gsabran/received_events","type":"User","site_admin":false},"created_at":"2016-08-04T00:37:04Z","updated_at":"2016-08-04T00:37:04Z","body":"I haven't look into Google yet, but will probably soon. If that's helpful, here's the full code I'm been using things for Facebook mobile auth in my code: https://gist.github.com/gsabran/8bab053beb05a0a5bf871b4caa00f9b6"}}
{"actor":{"display_login":"gsabran"}}