{"action":"created","comment":{"url":"https://api.github.com/repos/TFFLabs/SoundFoundry/pulls/comments/129339301","pull_request_review_id":52098375,"id":129339301,"diff_hunk":"@@ -0,0 +1,90 @@\n+import { Injectable, Inject} from '@angular/core';\n+import {Observable} from 'rxjs/Observable';\n+import 'rxjs/Rx';\n+\n+export interface AuthorizationToken {\n+  value?: string,\n+}\n+\n+@Injectable()\n+export class AuthorizationService {\n+\n+  constructor(@Inject(\"AuthorizationToken\") private authToken: AuthorizationToken) { }\n+\n+  login(){\n+    console.log('Logged IN!');\n+    var promise = new Promise((resolve, reject) => {\n+      var w = 400,\n+        h = 500,\n+        left = (screen.width / 2) - (w / 2),\n+        top = (screen.height / 2) - (h / 2);\n+\n+      var params = {\n+        client_id: 'd871ff65e9d94a08b33dd064cc879637',\n+        redirect_uri: 'http://localhost:4200/auth_callback',\n+        scope: 'user-follow-modify user-follow-read playlist-read-private playlist-read-collaborative playlist-modify-public playlist-modify-private user-library-read user-library-modify user-read-private',\n+        response_type: 'token'\n+      };\n+      var authCompleted = false;\n+      var authWindow = this.openDialog(\n+        'https://accounts.spotify.com/authorize?' + this.toQueryString(params),\n+        'Spotify',\n+        'menubar=no,location=no,resizable=yes,scrollbars=yes,status=no,width=' + w + ',height=' + h + ',top=' + top + ',left=' + left,\n+        () => {\n+          console.log('AUTH: ' + authCompleted);\n+          if (!authCompleted) {\n+            return reject('Login rejected error');\n+          }\n+        }\n+      );\n+\n+      var storageChanged = (e) => {\n+        if (e.key === 'foundry-spotify-token') {\n+          if (authWindow) {\n+            authWindow.close();\n+          }\n+          authCompleted = true;\n+          console.log('Token: '+ e.newValue);\n+          this.authToken.value = e.newValue;\n+          window.removeEventListener('storage', storageChanged, false);\n+\n+          return resolve(e.newValue);\n+        }\n+      };\n+      window.addEventListener('storage', storageChanged, false);\n+    });\n+\n+    return Observable.fromPromise(promise).catch(this.handleError);\n+  }\n+\n+  private toQueryString(obj: Object): string {\n+    var parts = [];\n+    for (let key in obj) {\n+      if (obj.hasOwnProperty(key)) {\n+        parts.push(encodeURIComponent(key) + '=' + encodeURIComponent(obj[key]));\n+      }\n+    };\n+    return parts.join('&');\n+  };\n+\n+  private openDialog(uri, name, options, cb) {","path":"src/app/authorization.service.ts","position":70,"original_position":70,"commit_id":"931b74794c58b385f4ec903195421f7e3a8f6105","original_commit_id":"931b74794c58b385f4ec903195421f7e3a8f6105","user":{"login":"Shinkei","id":348883,"avatar_url":"https://avatars3.githubusercontent.com/u/348883?v=4","gravatar_id":"","url":"https://api.github.com/users/Shinkei","html_url":"https://github.com/Shinkei","followers_url":"https://api.github.com/users/Shinkei/followers","following_url":"https://api.github.com/users/Shinkei/following{/other_user}","gists_url":"https://api.github.com/users/Shinkei/gists{/gist_id}","starred_url":"https://api.github.com/users/Shinkei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shinkei/subscriptions","organizations_url":"https://api.github.com/users/Shinkei/orgs","repos_url":"https://api.github.com/users/Shinkei/repos","events_url":"https://api.github.com/users/Shinkei/events{/privacy}","received_events_url":"https://api.github.com/users/Shinkei/received_events","type":"User","site_admin":false},"body":"podriamos dejar una tarea para hacer refactor de este codigo, que piensan? @TFFLabs/all ","created_at":"2017-07-25T15:26:32Z","updated_at":"2017-07-25T15:53:15Z","html_url":"https://github.com/TFFLabs/SoundFoundry/pull/11#discussion_r129339301","pull_request_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/TFFLabs/SoundFoundry/pulls/comments/129339301"},"html":{"href":"https://github.com/TFFLabs/SoundFoundry/pull/11#discussion_r129339301"},"pull_request":{"href":"https://api.github.com/repos/TFFLabs/SoundFoundry/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/TFFLabs/SoundFoundry/pulls/11","id":132199160,"html_url":"https://github.com/TFFLabs/SoundFoundry/pull/11","diff_url":"https://github.com/TFFLabs/SoundFoundry/pull/11.diff","patch_url":"https://github.com/TFFLabs/SoundFoundry/pull/11.patch","issue_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/issues/11","number":11,"state":"open","locked":false,"title":"Create Home Page #8, Home page, authorization flow.","user":{"login":"dahernandezt","id":14206871,"avatar_url":"https://avatars0.githubusercontent.com/u/14206871?v=4","gravatar_id":"","url":"https://api.github.com/users/dahernandezt","html_url":"https://github.com/dahernandezt","followers_url":"https://api.github.com/users/dahernandezt/followers","following_url":"https://api.github.com/users/dahernandezt/following{/other_user}","gists_url":"https://api.github.com/users/dahernandezt/gists{/gist_id}","starred_url":"https://api.github.com/users/dahernandezt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dahernandezt/subscriptions","organizations_url":"https://api.github.com/users/dahernandezt/orgs","repos_url":"https://api.github.com/users/dahernandezt/repos","events_url":"https://api.github.com/users/dahernandezt/events{/privacy}","received_events_url":"https://api.github.com/users/dahernandezt/received_events","type":"User","site_admin":false},"body":"Home page, authorization flow.","created_at":"2017-07-25T05:30:44Z","updated_at":"2017-07-25T15:53:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4cff7118e1ed18d8e3b5ea8d04bd2b08a9ea7f49","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/pulls/11/commits","review_comments_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/pulls/11/comments","review_comment_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/pulls/comments{/number}","comments_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/issues/11/comments","statuses_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/statuses/931b74794c58b385f4ec903195421f7e3a8f6105","head":{"label":"TFFLabs:Create_Home_Page","ref":"Create_Home_Page","sha":"931b74794c58b385f4ec903195421f7e3a8f6105","user":{"login":"TFFLabs","id":30160638,"avatar_url":"https://avatars1.githubusercontent.com/u/30160638?v=4","gravatar_id":"","url":"https://api.github.com/users/TFFLabs","html_url":"https://github.com/TFFLabs","followers_url":"https://api.github.com/users/TFFLabs/followers","following_url":"https://api.github.com/users/TFFLabs/following{/other_user}","gists_url":"https://api.github.com/users/TFFLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/TFFLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TFFLabs/subscriptions","organizations_url":"https://api.github.com/users/TFFLabs/orgs","repos_url":"https://api.github.com/users/TFFLabs/repos","events_url":"https://api.github.com/users/TFFLabs/events{/privacy}","received_events_url":"https://api.github.com/users/TFFLabs/received_events","type":"Organization","site_admin":false},"repo":{"id":97177036,"name":"SoundFoundry","full_name":"TFFLabs/SoundFoundry","owner":{"login":"TFFLabs","id":30160638,"avatar_url":"https://avatars1.githubusercontent.com/u/30160638?v=4","gravatar_id":"","url":"https://api.github.com/users/TFFLabs","html_url":"https://github.com/TFFLabs","followers_url":"https://api.github.com/users/TFFLabs/followers","following_url":"https://api.github.com/users/TFFLabs/following{/other_user}","gists_url":"https://api.github.com/users/TFFLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/TFFLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TFFLabs/subscriptions","organizations_url":"https://api.github.com/users/TFFLabs/orgs","repos_url":"https://api.github.com/users/TFFLabs/repos","events_url":"https://api.github.com/users/TFFLabs/events{/privacy}","received_events_url":"https://api.github.com/users/TFFLabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TFFLabs/SoundFoundry","description":"Social sound list for Spotify made with Angular and Firebase","fork":false,"url":"https://api.github.com/repos/TFFLabs/SoundFoundry","forks_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/forks","keys_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/teams","hooks_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/hooks","issue_events_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/issues/events{/number}","events_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/events","assignees_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/assignees{/user}","branches_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/branches{/branch}","tags_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/tags","blobs_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/git/refs{/sha}","trees_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/statuses/{sha}","languages_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/languages","stargazers_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/stargazers","contributors_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/contributors","subscribers_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/subscribers","subscription_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/subscription","commits_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/commits{/sha}","git_commits_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/git/commits{/sha}","comments_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/comments{/number}","issue_comment_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/issues/comments{/number}","contents_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/contents/{+path}","compare_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/merges","archive_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/downloads","issues_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/issues{/number}","pulls_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/pulls{/number}","milestones_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/milestones{/number}","notifications_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/labels{/name}","releases_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/releases{/id}","deployments_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/deployments","created_at":"2017-07-14T00:47:57Z","updated_at":"2017-07-14T23:13:42Z","pushed_at":"2017-07-25T15:49:29Z","git_url":"git://github.com/TFFLabs/SoundFoundry.git","ssh_url":"git@github.com:TFFLabs/SoundFoundry.git","clone_url":"https://github.com/TFFLabs/SoundFoundry.git","svn_url":"https://github.com/TFFLabs/SoundFoundry","homepage":"","size":183,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":9,"forks":1,"open_issues":9,"watchers":0,"default_branch":"master"}},"base":{"label":"TFFLabs:master","ref":"master","sha":"ffa30225464f53d56544a137096aced84c79c276","user":{"login":"TFFLabs","id":30160638,"avatar_url":"https://avatars1.githubusercontent.com/u/30160638?v=4","gravatar_id":"","url":"https://api.github.com/users/TFFLabs","html_url":"https://github.com/TFFLabs","followers_url":"https://api.github.com/users/TFFLabs/followers","following_url":"https://api.github.com/users/TFFLabs/following{/other_user}","gists_url":"https://api.github.com/users/TFFLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/TFFLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TFFLabs/subscriptions","organizations_url":"https://api.github.com/users/TFFLabs/orgs","repos_url":"https://api.github.com/users/TFFLabs/repos","events_url":"https://api.github.com/users/TFFLabs/events{/privacy}","received_events_url":"https://api.github.com/users/TFFLabs/received_events","type":"Organization","site_admin":false},"repo":{"id":97177036,"name":"SoundFoundry","full_name":"TFFLabs/SoundFoundry","owner":{"login":"TFFLabs","id":30160638,"avatar_url":"https://avatars1.githubusercontent.com/u/30160638?v=4","gravatar_id":"","url":"https://api.github.com/users/TFFLabs","html_url":"https://github.com/TFFLabs","followers_url":"https://api.github.com/users/TFFLabs/followers","following_url":"https://api.github.com/users/TFFLabs/following{/other_user}","gists_url":"https://api.github.com/users/TFFLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/TFFLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TFFLabs/subscriptions","organizations_url":"https://api.github.com/users/TFFLabs/orgs","repos_url":"https://api.github.com/users/TFFLabs/repos","events_url":"https://api.github.com/users/TFFLabs/events{/privacy}","received_events_url":"https://api.github.com/users/TFFLabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TFFLabs/SoundFoundry","description":"Social sound list for Spotify made with Angular and Firebase","fork":false,"url":"https://api.github.com/repos/TFFLabs/SoundFoundry","forks_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/forks","keys_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/teams","hooks_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/hooks","issue_events_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/issues/events{/number}","events_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/events","assignees_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/assignees{/user}","branches_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/branches{/branch}","tags_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/tags","blobs_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/git/refs{/sha}","trees_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/statuses/{sha}","languages_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/languages","stargazers_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/stargazers","contributors_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/contributors","subscribers_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/subscribers","subscription_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/subscription","commits_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/commits{/sha}","git_commits_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/git/commits{/sha}","comments_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/comments{/number}","issue_comment_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/issues/comments{/number}","contents_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/contents/{+path}","compare_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/merges","archive_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/downloads","issues_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/issues{/number}","pulls_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/pulls{/number}","milestones_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/milestones{/number}","notifications_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/labels{/name}","releases_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/releases{/id}","deployments_url":"https://api.github.com/repos/TFFLabs/SoundFoundry/deployments","created_at":"2017-07-14T00:47:57Z","updated_at":"2017-07-14T23:13:42Z","pushed_at":"2017-07-25T15:49:29Z","git_url":"git://github.com/TFFLabs/SoundFoundry.git","ssh_url":"git@github.com:TFFLabs/SoundFoundry.git","clone_url":"https://github.com/TFFLabs/SoundFoundry.git","svn_url":"https://github.com/TFFLabs/SoundFoundry","homepage":"","size":183,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":9,"forks":1,"open_issues":9,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/TFFLabs/SoundFoundry/pulls/11"},"html":{"href":"https://github.com/TFFLabs/SoundFoundry/pull/11"},"issue":{"href":"https://api.github.com/repos/TFFLabs/SoundFoundry/issues/11"},"comments":{"href":"https://api.github.com/repos/TFFLabs/SoundFoundry/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/TFFLabs/SoundFoundry/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/TFFLabs/SoundFoundry/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/TFFLabs/SoundFoundry/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/TFFLabs/SoundFoundry/statuses/931b74794c58b385f4ec903195421f7e3a8f6105"}}}}
{"actor":{"display_login":"Shinkei"}}