{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/olympia/pulls/comments/45257812","id":45257812,"diff_hunk":"@@ -0,0 +1,35 @@\n+# Don't import any django stuff here.\n+\n+import requests\n+\n+\n+def fxa_identify(code, config=None):\n+    \"\"\"Get an FxA profile for an access token. If idenficiation fails return\n+    an empty dict.\"\"\"\n+    token = get_fxa_token(code, config).get('access_token')\n+    if token:\n+        return get_fxa_profile(token, config)\n+    else:\n+        return {}\n+\n+\n+def get_fxa_token(code, config):\n+    response = requests.post(config['oauth_uri'] + '/token', data={\n+        'code': code,\n+        'client_id': config['client_id'],\n+        'client_secret': config['client_secret'],\n+    })\n+    if response.status_code == 200:\n+        return response.json()\n+    else:\n+        return {}\n+\n+\n+def get_fxa_profile(token, config):\n+    response = requests.get(config['profile_uri'] + '/profile', headers={\n+        'Authorization': 'Bearer {token}'.format(token=token),\n+    })\n+    if response.status_code == 200:\n+        return response.json()\n+    else:\n+        return {}","path":"apps/accounts/verify.py","position":35,"original_position":35,"commit_id":"e5de1c39393a1ae937019e56d53fb5b394de2370","original_commit_id":"e5de1c39393a1ae937019e56d53fb5b394de2370","user":{"login":"kumar303","id":55398,"avatar_url":"https://avatars.githubusercontent.com/u/55398?v=3","gravatar_id":"","url":"https://api.github.com/users/kumar303","html_url":"https://github.com/kumar303","followers_url":"https://api.github.com/users/kumar303/followers","following_url":"https://api.github.com/users/kumar303/following{/other_user}","gists_url":"https://api.github.com/users/kumar303/gists{/gist_id}","starred_url":"https://api.github.com/users/kumar303/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kumar303/subscriptions","organizations_url":"https://api.github.com/users/kumar303/orgs","repos_url":"https://api.github.com/users/kumar303/repos","events_url":"https://api.github.com/users/kumar303/events{/privacy}","received_events_url":"https://api.github.com/users/kumar303/received_events","type":"User","site_admin":false},"body":"and here","created_at":"2015-11-18T20:49:38Z","updated_at":"2015-11-18T20:49:38Z","html_url":"https://github.com/mozilla/olympia/pull/938#discussion_r45257812","pull_request_url":"https://api.github.com/repos/mozilla/olympia/pulls/938","_links":{"self":{"href":"https://api.github.com/repos/mozilla/olympia/pulls/comments/45257812"},"html":{"href":"https://github.com/mozilla/olympia/pull/938#discussion_r45257812"},"pull_request":{"href":"https://api.github.com/repos/mozilla/olympia/pulls/938"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/olympia/pulls/938","id":50885803,"html_url":"https://github.com/mozilla/olympia/pull/938","diff_url":"https://github.com/mozilla/olympia/pull/938.diff","patch_url":"https://github.com/mozilla/olympia/pull/938.patch","issue_url":"https://api.github.com/repos/mozilla/olympia/issues/938","number":938,"state":"open","locked":false,"title":"Initial Firefox Accounts login","user":{"login":"mstriemer","id":211578,"avatar_url":"https://avatars.githubusercontent.com/u/211578?v=3","gravatar_id":"","url":"https://api.github.com/users/mstriemer","html_url":"https://github.com/mstriemer","followers_url":"https://api.github.com/users/mstriemer/followers","following_url":"https://api.github.com/users/mstriemer/following{/other_user}","gists_url":"https://api.github.com/users/mstriemer/gists{/gist_id}","starred_url":"https://api.github.com/users/mstriemer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mstriemer/subscriptions","organizations_url":"https://api.github.com/users/mstriemer/orgs","repos_url":"https://api.github.com/users/mstriemer/repos","events_url":"https://api.github.com/users/mstriemer/events{/privacy}","received_events_url":"https://api.github.com/users/mstriemer/received_events","type":"User","site_admin":false},"body":"Fixes #863, fixes #864\n\nIf you delete `conftest.py` and `pytest.ini` then you can test the verify module really quickly using `py.test apps/accounts/tests/test_verify.py`. It unfortunately doesn't have much logic but maybe I can move some of the view code into it.\n\nRunning just the one file (without the config files) runs locally in 0.4s (real time via `time`) and in docker takes about 3.25s real time. Running it with the config files locally takes 1.1s. I'm not sure if there's a way to prevent loading those files if they aren't needed.","created_at":"2015-11-17T00:03:21Z","updated_at":"2015-11-18T20:49:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f0bef3790dc0ca34f2b00a3420120bcf9a19b66c","assignee":{"login":"kumar303","id":55398,"avatar_url":"https://avatars.githubusercontent.com/u/55398?v=3","gravatar_id":"","url":"https://api.github.com/users/kumar303","html_url":"https://github.com/kumar303","followers_url":"https://api.github.com/users/kumar303/followers","following_url":"https://api.github.com/users/kumar303/following{/other_user}","gists_url":"https://api.github.com/users/kumar303/gists{/gist_id}","starred_url":"https://api.github.com/users/kumar303/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kumar303/subscriptions","organizations_url":"https://api.github.com/users/kumar303/orgs","repos_url":"https://api.github.com/users/kumar303/repos","events_url":"https://api.github.com/users/kumar303/events{/privacy}","received_events_url":"https://api.github.com/users/kumar303/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/olympia/pulls/938/commits","review_comments_url":"https://api.github.com/repos/mozilla/olympia/pulls/938/comments","review_comment_url":"https://api.github.com/repos/mozilla/olympia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/olympia/issues/938/comments","statuses_url":"https://api.github.com/repos/mozilla/olympia/statuses/e5de1c39393a1ae937019e56d53fb5b394de2370","head":{"label":"mstriemer:fxa-config","ref":"fxa-config","sha":"e5de1c39393a1ae937019e56d53fb5b394de2370","user":{"login":"mstriemer","id":211578,"avatar_url":"https://avatars.githubusercontent.com/u/211578?v=3","gravatar_id":"","url":"https://api.github.com/users/mstriemer","html_url":"https://github.com/mstriemer","followers_url":"https://api.github.com/users/mstriemer/followers","following_url":"https://api.github.com/users/mstriemer/following{/other_user}","gists_url":"https://api.github.com/users/mstriemer/gists{/gist_id}","starred_url":"https://api.github.com/users/mstriemer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mstriemer/subscriptions","organizations_url":"https://api.github.com/users/mstriemer/orgs","repos_url":"https://api.github.com/users/mstriemer/repos","events_url":"https://api.github.com/users/mstriemer/events{/privacy}","received_events_url":"https://api.github.com/users/mstriemer/received_events","type":"User","site_admin":false},"repo":{"id":18221347,"name":"olympia","full_name":"mstriemer/olympia","owner":{"login":"mstriemer","id":211578,"avatar_url":"https://avatars.githubusercontent.com/u/211578?v=3","gravatar_id":"","url":"https://api.github.com/users/mstriemer","html_url":"https://github.com/mstriemer","followers_url":"https://api.github.com/users/mstriemer/followers","following_url":"https://api.github.com/users/mstriemer/following{/other_user}","gists_url":"https://api.github.com/users/mstriemer/gists{/gist_id}","starred_url":"https://api.github.com/users/mstriemer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mstriemer/subscriptions","organizations_url":"https://api.github.com/users/mstriemer/orgs","repos_url":"https://api.github.com/users/mstriemer/repos","events_url":"https://api.github.com/users/mstriemer/events{/privacy}","received_events_url":"https://api.github.com/users/mstriemer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mstriemer/olympia","description":"AMO, reloaded.","fork":true,"url":"https://api.github.com/repos/mstriemer/olympia","forks_url":"https://api.github.com/repos/mstriemer/olympia/forks","keys_url":"https://api.github.com/repos/mstriemer/olympia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mstriemer/olympia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mstriemer/olympia/teams","hooks_url":"https://api.github.com/repos/mstriemer/olympia/hooks","issue_events_url":"https://api.github.com/repos/mstriemer/olympia/issues/events{/number}","events_url":"https://api.github.com/repos/mstriemer/olympia/events","assignees_url":"https://api.github.com/repos/mstriemer/olympia/assignees{/user}","branches_url":"https://api.github.com/repos/mstriemer/olympia/branches{/branch}","tags_url":"https://api.github.com/repos/mstriemer/olympia/tags","blobs_url":"https://api.github.com/repos/mstriemer/olympia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mstriemer/olympia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mstriemer/olympia/git/refs{/sha}","trees_url":"https://api.github.com/repos/mstriemer/olympia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mstriemer/olympia/statuses/{sha}","languages_url":"https://api.github.com/repos/mstriemer/olympia/languages","stargazers_url":"https://api.github.com/repos/mstriemer/olympia/stargazers","contributors_url":"https://api.github.com/repos/mstriemer/olympia/contributors","subscribers_url":"https://api.github.com/repos/mstriemer/olympia/subscribers","subscription_url":"https://api.github.com/repos/mstriemer/olympia/subscription","commits_url":"https://api.github.com/repos/mstriemer/olympia/commits{/sha}","git_commits_url":"https://api.github.com/repos/mstriemer/olympia/git/commits{/sha}","comments_url":"https://api.github.com/repos/mstriemer/olympia/comments{/number}","issue_comment_url":"https://api.github.com/repos/mstriemer/olympia/issues/comments{/number}","contents_url":"https://api.github.com/repos/mstriemer/olympia/contents/{+path}","compare_url":"https://api.github.com/repos/mstriemer/olympia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mstriemer/olympia/merges","archive_url":"https://api.github.com/repos/mstriemer/olympia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mstriemer/olympia/downloads","issues_url":"https://api.github.com/repos/mstriemer/olympia/issues{/number}","pulls_url":"https://api.github.com/repos/mstriemer/olympia/pulls{/number}","milestones_url":"https://api.github.com/repos/mstriemer/olympia/milestones{/number}","notifications_url":"https://api.github.com/repos/mstriemer/olympia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mstriemer/olympia/labels{/name}","releases_url":"https://api.github.com/repos/mstriemer/olympia/releases{/id}","created_at":"2014-03-28T17:58:28Z","updated_at":"2015-08-04T16:05:57Z","pushed_at":"2015-11-17T19:14:05Z","git_url":"git://github.com/mstriemer/olympia.git","ssh_url":"git@github.com:mstriemer/olympia.git","clone_url":"https://github.com/mstriemer/olympia.git","svn_url":"https://github.com/mstriemer/olympia","homepage":"","size":441154,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"708c42c0502f8b742181b9f42dc106c613e9c4f6","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":16416867,"name":"olympia","full_name":"mozilla/olympia","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/olympia","description":"addons.mozilla.org, reloaded.","fork":false,"url":"https://api.github.com/repos/mozilla/olympia","forks_url":"https://api.github.com/repos/mozilla/olympia/forks","keys_url":"https://api.github.com/repos/mozilla/olympia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/olympia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/olympia/teams","hooks_url":"https://api.github.com/repos/mozilla/olympia/hooks","issue_events_url":"https://api.github.com/repos/mozilla/olympia/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/olympia/events","assignees_url":"https://api.github.com/repos/mozilla/olympia/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/olympia/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/olympia/tags","blobs_url":"https://api.github.com/repos/mozilla/olympia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/olympia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/olympia/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/olympia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/olympia/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/olympia/languages","stargazers_url":"https://api.github.com/repos/mozilla/olympia/stargazers","contributors_url":"https://api.github.com/repos/mozilla/olympia/contributors","subscribers_url":"https://api.github.com/repos/mozilla/olympia/subscribers","subscription_url":"https://api.github.com/repos/mozilla/olympia/subscription","commits_url":"https://api.github.com/repos/mozilla/olympia/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/olympia/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/olympia/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/olympia/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/olympia/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/olympia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/olympia/merges","archive_url":"https://api.github.com/repos/mozilla/olympia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/olympia/downloads","issues_url":"https://api.github.com/repos/mozilla/olympia/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/olympia/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/olympia/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/olympia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/olympia/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/olympia/releases{/id}","created_at":"2014-01-31T18:44:15Z","updated_at":"2015-11-05T17:24:17Z","pushed_at":"2015-11-18T16:06:10Z","git_url":"git://github.com/mozilla/olympia.git","ssh_url":"git@github.com:mozilla/olympia.git","clone_url":"https://github.com/mozilla/olympia.git","svn_url":"https://github.com/mozilla/olympia","homepage":"https://addons.mozilla.org/","size":443107,"stargazers_count":60,"watchers_count":60,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":119,"mirror_url":null,"open_issues_count":41,"forks":119,"open_issues":41,"watchers":60,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/olympia/pulls/938"},"html":{"href":"https://github.com/mozilla/olympia/pull/938"},"issue":{"href":"https://api.github.com/repos/mozilla/olympia/issues/938"},"comments":{"href":"https://api.github.com/repos/mozilla/olympia/issues/938/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/olympia/pulls/938/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/olympia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/olympia/pulls/938/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/olympia/statuses/e5de1c39393a1ae937019e56d53fb5b394de2370"}}}}