{"action":"created","issue":{"url":"https://api.github.com/repos/stormpath/stormpath-sdk-node/issues/248","labels_url":"https://api.github.com/repos/stormpath/stormpath-sdk-node/issues/248/labels{/name}","comments_url":"https://api.github.com/repos/stormpath/stormpath-sdk-node/issues/248/comments","events_url":"https://api.github.com/repos/stormpath/stormpath-sdk-node/issues/248/events","html_url":"https://github.com/stormpath/stormpath-sdk-node/pull/248","id":112347422,"number":248,"title":"Feature: Async scope factory","user":{"login":"typerandom","id":1331778,"avatar_url":"https://avatars.githubusercontent.com/u/1331778?v=3","gravatar_id":"","url":"https://api.github.com/users/typerandom","html_url":"https://github.com/typerandom","followers_url":"https://api.github.com/users/typerandom/followers","following_url":"https://api.github.com/users/typerandom/following{/other_user}","gists_url":"https://api.github.com/users/typerandom/gists{/gist_id}","starred_url":"https://api.github.com/users/typerandom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/typerandom/subscriptions","organizations_url":"https://api.github.com/users/typerandom/orgs","repos_url":"https://api.github.com/users/typerandom/repos","events_url":"https://api.github.com/users/typerandom/events{/privacy}","received_events_url":"https://api.github.com/users/typerandom/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/stormpath/stormpath-sdk-node/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-10-20T11:32:33Z","updated_at":"2015-10-22T13:58:38Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/stormpath/stormpath-sdk-node/pulls/248","html_url":"https://github.com/stormpath/stormpath-sdk-node/pull/248","diff_url":"https://github.com/stormpath/stormpath-sdk-node/pull/248.diff","patch_url":"https://github.com/stormpath/stormpath-sdk-node/pull/248.patch"},"body":"Adds the ability for a OAuthBasicExchangeAuthenticator scope factory to resolve scopes asynchronously.\r\n\r\nPreviously it was only possible for scopes to be resolved synchronously by the scope factory. As shown below:\r\n\r\n```js\r\napp.authenticateApiRequest({\r\n  scopeFactory: function(account, requestedScope){\r\n    return ['myscope'];\r\n  }\r\n}, onResult);\r\n```\r\n\r\nBut now it's also possible to do so by calling the optional callback argument. As shown below:\r\n\r\n```js\r\napp.authenticateApiRequest({\r\n  scopeFactory: function(account, requestedScope, callback){\r\n    callback(null, ['myscope']);\r\n  }\r\n}, onResult);\r\n```\r\n\r\n**Note:** If the scope factory returns a value (not undefined) then it is assumed that this is the scope result. Else it is assumed that the scope result will be provided through the provided callback. The reason that both cases are supported is because of backward compatibility.\r\n\r\nCloses #171."},"comment":{"url":"https://api.github.com/repos/stormpath/stormpath-sdk-node/issues/comments/150231764","html_url":"https://github.com/stormpath/stormpath-sdk-node/pull/248#issuecomment-150231764","issue_url":"https://api.github.com/repos/stormpath/stormpath-sdk-node/issues/248","id":150231764,"user":{"login":"typerandom","id":1331778,"avatar_url":"https://avatars.githubusercontent.com/u/1331778?v=3","gravatar_id":"","url":"https://api.github.com/users/typerandom","html_url":"https://github.com/typerandom","followers_url":"https://api.github.com/users/typerandom/followers","following_url":"https://api.github.com/users/typerandom/following{/other_user}","gists_url":"https://api.github.com/users/typerandom/gists{/gist_id}","starred_url":"https://api.github.com/users/typerandom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/typerandom/subscriptions","organizations_url":"https://api.github.com/users/typerandom/orgs","repos_url":"https://api.github.com/users/typerandom/repos","events_url":"https://api.github.com/users/typerandom/events{/privacy}","received_events_url":"https://api.github.com/users/typerandom/received_events","type":"User","site_admin":false},"created_at":"2015-10-22T13:58:38Z","updated_at":"2015-10-22T13:58:38Z","body":"Coverage is fixed. Please review."}}