{"action":"created","comment":{"url":"https://api.github.com/repos/okta/okta-auth-js/pulls/comments/72517922","id":72517922,"diff_hunk":"@@ -32,7 +36,34 @@ function remove(storage, key) {\n   storage.setTokenStorage(tokenStorage);\n }\n \n-function TokenManager(options) {\n+function refresh(sdk, storage, key) {\n+  try {\n+    var token = get(storage, key);\n+    if (!token) {\n+      throw new AuthSdkError('The tokenManager has no token for the key: ' + key);\n+    }\n+  } catch (e) {\n+    return Q.reject(e);\n+  }\n+\n+  var responseType;\n+  if (token.accessToken) {\n+    responseType = 'token';\n+  } else {\n+    responseType = 'id_token';\n+  }\n+\n+  return sdk.token.getWithoutPrompt({\n+    responseType: responseType,\n+    scope: token.scopes\n+  })\n+  .then(function(freshToken) {\n+    add(storage, key, freshToken);\n+    return freshToken;\n+  });","path":"lib/TokenManager.js","position":51,"original_position":51,"commit_id":"719d2fce69753c0a37fce9acb8a0bd90b0b3c6b7","original_commit_id":"719d2fce69753c0a37fce9acb8a0bd90b0b3c6b7","user":{"login":"lboyette-okta","id":6387101,"avatar_url":"https://avatars.githubusercontent.com/u/6387101?v=3","gravatar_id":"","url":"https://api.github.com/users/lboyette-okta","html_url":"https://github.com/lboyette-okta","followers_url":"https://api.github.com/users/lboyette-okta/followers","following_url":"https://api.github.com/users/lboyette-okta/following{/other_user}","gists_url":"https://api.github.com/users/lboyette-okta/gists{/gist_id}","starred_url":"https://api.github.com/users/lboyette-okta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lboyette-okta/subscriptions","organizations_url":"https://api.github.com/users/lboyette-okta/orgs","repos_url":"https://api.github.com/users/lboyette-okta/repos","events_url":"https://api.github.com/users/lboyette-okta/events{/privacy}","received_events_url":"https://api.github.com/users/lboyette-okta/received_events","type":"User","site_admin":false},"body":"I think it makes sense to remove the existing token; I'll add that.\r\n\r\nListening to events will be in a follow-up PR, probably bundled with autoRefresh.","created_at":"2016-07-27T20:35:07Z","updated_at":"2016-07-27T20:35:07Z","html_url":"https://github.com/okta/okta-auth-js/pull/35#discussion_r72517922","pull_request_url":"https://api.github.com/repos/okta/okta-auth-js/pulls/35","_links":{"self":{"href":"https://api.github.com/repos/okta/okta-auth-js/pulls/comments/72517922"},"html":{"href":"https://github.com/okta/okta-auth-js/pull/35#discussion_r72517922"},"pull_request":{"href":"https://api.github.com/repos/okta/okta-auth-js/pulls/35"}}},"pull_request":{"url":"https://api.github.com/repos/okta/okta-auth-js/pulls/35","id":78968262,"html_url":"https://github.com/okta/okta-auth-js/pull/35","diff_url":"https://github.com/okta/okta-auth-js/pull/35.diff","patch_url":"https://github.com/okta/okta-auth-js/pull/35.patch","issue_url":"https://api.github.com/repos/okta/okta-auth-js/issues/35","number":35,"state":"open","locked":false,"title":"Add tokenManager.refresh","user":{"login":"lboyette-okta","id":6387101,"avatar_url":"https://avatars.githubusercontent.com/u/6387101?v=3","gravatar_id":"","url":"https://api.github.com/users/lboyette-okta","html_url":"https://github.com/lboyette-okta","followers_url":"https://api.github.com/users/lboyette-okta/followers","following_url":"https://api.github.com/users/lboyette-okta/following{/other_user}","gists_url":"https://api.github.com/users/lboyette-okta/gists{/gist_id}","starred_url":"https://api.github.com/users/lboyette-okta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lboyette-okta/subscriptions","organizations_url":"https://api.github.com/users/lboyette-okta/orgs","repos_url":"https://api.github.com/users/lboyette-okta/repos","events_url":"https://api.github.com/users/lboyette-okta/events{/privacy}","received_events_url":"https://api.github.com/users/lboyette-okta/received_events","type":"User","site_admin":false},"body":"Resolves: OKTA-94715\r\n\r\n@rchild-okta \r\n@manueltanzi-okta ","created_at":"2016-07-27T05:45:40Z","updated_at":"2016-07-27T20:35:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fa62a79410edb5216321b7dd9d4d0ac3ae791644","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/okta/okta-auth-js/pulls/35/commits","review_comments_url":"https://api.github.com/repos/okta/okta-auth-js/pulls/35/comments","review_comment_url":"https://api.github.com/repos/okta/okta-auth-js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/okta/okta-auth-js/issues/35/comments","statuses_url":"https://api.github.com/repos/okta/okta-auth-js/statuses/719d2fce69753c0a37fce9acb8a0bd90b0b3c6b7","head":{"label":"okta:lb-94715-tokenManager-refresh","ref":"lb-94715-tokenManager-refresh","sha":"719d2fce69753c0a37fce9acb8a0bd90b0b3c6b7","user":{"login":"okta","id":362460,"avatar_url":"https://avatars.githubusercontent.com/u/362460?v=3","gravatar_id":"","url":"https://api.github.com/users/okta","html_url":"https://github.com/okta","followers_url":"https://api.github.com/users/okta/followers","following_url":"https://api.github.com/users/okta/following{/other_user}","gists_url":"https://api.github.com/users/okta/gists{/gist_id}","starred_url":"https://api.github.com/users/okta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/okta/subscriptions","organizations_url":"https://api.github.com/users/okta/orgs","repos_url":"https://api.github.com/users/okta/repos","events_url":"https://api.github.com/users/okta/events{/privacy}","received_events_url":"https://api.github.com/users/okta/received_events","type":"Organization","site_admin":false},"repo":{"id":56723632,"name":"okta-auth-js","full_name":"okta/okta-auth-js","owner":{"login":"okta","id":362460,"avatar_url":"https://avatars.githubusercontent.com/u/362460?v=3","gravatar_id":"","url":"https://api.github.com/users/okta","html_url":"https://github.com/okta","followers_url":"https://api.github.com/users/okta/followers","following_url":"https://api.github.com/users/okta/following{/other_user}","gists_url":"https://api.github.com/users/okta/gists{/gist_id}","starred_url":"https://api.github.com/users/okta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/okta/subscriptions","organizations_url":"https://api.github.com/users/okta/orgs","repos_url":"https://api.github.com/users/okta/repos","events_url":"https://api.github.com/users/okta/events{/privacy}","received_events_url":"https://api.github.com/users/okta/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/okta/okta-auth-js","description":"The official js wrapper around Okta's auth API","fork":false,"url":"https://api.github.com/repos/okta/okta-auth-js","forks_url":"https://api.github.com/repos/okta/okta-auth-js/forks","keys_url":"https://api.github.com/repos/okta/okta-auth-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/okta/okta-auth-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/okta/okta-auth-js/teams","hooks_url":"https://api.github.com/repos/okta/okta-auth-js/hooks","issue_events_url":"https://api.github.com/repos/okta/okta-auth-js/issues/events{/number}","events_url":"https://api.github.com/repos/okta/okta-auth-js/events","assignees_url":"https://api.github.com/repos/okta/okta-auth-js/assignees{/user}","branches_url":"https://api.github.com/repos/okta/okta-auth-js/branches{/branch}","tags_url":"https://api.github.com/repos/okta/okta-auth-js/tags","blobs_url":"https://api.github.com/repos/okta/okta-auth-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/okta/okta-auth-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/okta/okta-auth-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/okta/okta-auth-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/okta/okta-auth-js/statuses/{sha}","languages_url":"https://api.github.com/repos/okta/okta-auth-js/languages","stargazers_url":"https://api.github.com/repos/okta/okta-auth-js/stargazers","contributors_url":"https://api.github.com/repos/okta/okta-auth-js/contributors","subscribers_url":"https://api.github.com/repos/okta/okta-auth-js/subscribers","subscription_url":"https://api.github.com/repos/okta/okta-auth-js/subscription","commits_url":"https://api.github.com/repos/okta/okta-auth-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/okta/okta-auth-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/okta/okta-auth-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/okta/okta-auth-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/okta/okta-auth-js/contents/{+path}","compare_url":"https://api.github.com/repos/okta/okta-auth-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/okta/okta-auth-js/merges","archive_url":"https://api.github.com/repos/okta/okta-auth-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/okta/okta-auth-js/downloads","issues_url":"https://api.github.com/repos/okta/okta-auth-js/issues{/number}","pulls_url":"https://api.github.com/repos/okta/okta-auth-js/pulls{/number}","milestones_url":"https://api.github.com/repos/okta/okta-auth-js/milestones{/number}","notifications_url":"https://api.github.com/repos/okta/okta-auth-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/okta/okta-auth-js/labels{/name}","releases_url":"https://api.github.com/repos/okta/okta-auth-js/releases{/id}","deployments_url":"https://api.github.com/repos/okta/okta-auth-js/deployments","created_at":"2016-04-20T21:55:56Z","updated_at":"2016-07-13T01:24:28Z","pushed_at":"2016-07-27T17:33:28Z","git_url":"git://github.com/okta/okta-auth-js.git","ssh_url":"git@github.com:okta/okta-auth-js.git","clone_url":"https://github.com/okta/okta-auth-js.git","svn_url":"https://github.com/okta/okta-auth-js","homepage":null,"size":218,"stargazers_count":7,"watchers_count":7,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":7,"default_branch":"master"}},"base":{"label":"okta:master","ref":"master","sha":"cde30657598cbd0eb213f5b130021d6f87c17002","user":{"login":"okta","id":362460,"avatar_url":"https://avatars.githubusercontent.com/u/362460?v=3","gravatar_id":"","url":"https://api.github.com/users/okta","html_url":"https://github.com/okta","followers_url":"https://api.github.com/users/okta/followers","following_url":"https://api.github.com/users/okta/following{/other_user}","gists_url":"https://api.github.com/users/okta/gists{/gist_id}","starred_url":"https://api.github.com/users/okta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/okta/subscriptions","organizations_url":"https://api.github.com/users/okta/orgs","repos_url":"https://api.github.com/users/okta/repos","events_url":"https://api.github.com/users/okta/events{/privacy}","received_events_url":"https://api.github.com/users/okta/received_events","type":"Organization","site_admin":false},"repo":{"id":56723632,"name":"okta-auth-js","full_name":"okta/okta-auth-js","owner":{"login":"okta","id":362460,"avatar_url":"https://avatars.githubusercontent.com/u/362460?v=3","gravatar_id":"","url":"https://api.github.com/users/okta","html_url":"https://github.com/okta","followers_url":"https://api.github.com/users/okta/followers","following_url":"https://api.github.com/users/okta/following{/other_user}","gists_url":"https://api.github.com/users/okta/gists{/gist_id}","starred_url":"https://api.github.com/users/okta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/okta/subscriptions","organizations_url":"https://api.github.com/users/okta/orgs","repos_url":"https://api.github.com/users/okta/repos","events_url":"https://api.github.com/users/okta/events{/privacy}","received_events_url":"https://api.github.com/users/okta/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/okta/okta-auth-js","description":"The official js wrapper around Okta's auth API","fork":false,"url":"https://api.github.com/repos/okta/okta-auth-js","forks_url":"https://api.github.com/repos/okta/okta-auth-js/forks","keys_url":"https://api.github.com/repos/okta/okta-auth-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/okta/okta-auth-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/okta/okta-auth-js/teams","hooks_url":"https://api.github.com/repos/okta/okta-auth-js/hooks","issue_events_url":"https://api.github.com/repos/okta/okta-auth-js/issues/events{/number}","events_url":"https://api.github.com/repos/okta/okta-auth-js/events","assignees_url":"https://api.github.com/repos/okta/okta-auth-js/assignees{/user}","branches_url":"https://api.github.com/repos/okta/okta-auth-js/branches{/branch}","tags_url":"https://api.github.com/repos/okta/okta-auth-js/tags","blobs_url":"https://api.github.com/repos/okta/okta-auth-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/okta/okta-auth-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/okta/okta-auth-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/okta/okta-auth-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/okta/okta-auth-js/statuses/{sha}","languages_url":"https://api.github.com/repos/okta/okta-auth-js/languages","stargazers_url":"https://api.github.com/repos/okta/okta-auth-js/stargazers","contributors_url":"https://api.github.com/repos/okta/okta-auth-js/contributors","subscribers_url":"https://api.github.com/repos/okta/okta-auth-js/subscribers","subscription_url":"https://api.github.com/repos/okta/okta-auth-js/subscription","commits_url":"https://api.github.com/repos/okta/okta-auth-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/okta/okta-auth-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/okta/okta-auth-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/okta/okta-auth-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/okta/okta-auth-js/contents/{+path}","compare_url":"https://api.github.com/repos/okta/okta-auth-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/okta/okta-auth-js/merges","archive_url":"https://api.github.com/repos/okta/okta-auth-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/okta/okta-auth-js/downloads","issues_url":"https://api.github.com/repos/okta/okta-auth-js/issues{/number}","pulls_url":"https://api.github.com/repos/okta/okta-auth-js/pulls{/number}","milestones_url":"https://api.github.com/repos/okta/okta-auth-js/milestones{/number}","notifications_url":"https://api.github.com/repos/okta/okta-auth-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/okta/okta-auth-js/labels{/name}","releases_url":"https://api.github.com/repos/okta/okta-auth-js/releases{/id}","deployments_url":"https://api.github.com/repos/okta/okta-auth-js/deployments","created_at":"2016-04-20T21:55:56Z","updated_at":"2016-07-13T01:24:28Z","pushed_at":"2016-07-27T17:33:28Z","git_url":"git://github.com/okta/okta-auth-js.git","ssh_url":"git@github.com:okta/okta-auth-js.git","clone_url":"https://github.com/okta/okta-auth-js.git","svn_url":"https://github.com/okta/okta-auth-js","homepage":null,"size":218,"stargazers_count":7,"watchers_count":7,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/okta/okta-auth-js/pulls/35"},"html":{"href":"https://github.com/okta/okta-auth-js/pull/35"},"issue":{"href":"https://api.github.com/repos/okta/okta-auth-js/issues/35"},"comments":{"href":"https://api.github.com/repos/okta/okta-auth-js/issues/35/comments"},"review_comments":{"href":"https://api.github.com/repos/okta/okta-auth-js/pulls/35/comments"},"review_comment":{"href":"https://api.github.com/repos/okta/okta-auth-js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/okta/okta-auth-js/pulls/35/commits"},"statuses":{"href":"https://api.github.com/repos/okta/okta-auth-js/statuses/719d2fce69753c0a37fce9acb8a0bd90b0b3c6b7"}}}}
{"actor":{"display_login":"lboyette-okta"}}