{"action":"created","issue":{"url":"https://api.github.com/repos/ably/ably-js/issues/21","labels_url":"https://api.github.com/repos/ably/ably-js/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/ably/ably-js/issues/21/comments","events_url":"https://api.github.com/repos/ably/ably-js/issues/21/events","html_url":"https://github.com/ably/ably-js/issues/21","id":64111192,"number":21,"title":"createTokenRequest without key option","user":{"login":"mattheworiordan","id":43789,"avatar_url":"https://avatars.githubusercontent.com/u/43789?v=3","gravatar_id":"","url":"https://api.github.com/users/mattheworiordan","html_url":"https://github.com/mattheworiordan","followers_url":"https://api.github.com/users/mattheworiordan/followers","following_url":"https://api.github.com/users/mattheworiordan/following{/other_user}","gists_url":"https://api.github.com/users/mattheworiordan/gists{/gist_id}","starred_url":"https://api.github.com/users/mattheworiordan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattheworiordan/subscriptions","organizations_url":"https://api.github.com/users/mattheworiordan/orgs","repos_url":"https://api.github.com/users/mattheworiordan/repos","events_url":"https://api.github.com/users/mattheworiordan/events{/privacy}","received_events_url":"https://api.github.com/users/mattheworiordan/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ably/ably-js/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/ably/ably-js/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-24T22:04:55Z","updated_at":"2015-03-24T22:19:22Z","closed_at":null,"body":"In the Ably Ruby library when calling [createTokenRequest](https://github.com/ably/ably-ruby/blob/master/lib/ably/auth.rb#L192), if an API key has been specified in the constructor, then there is no need to specify a key ID in the createTokenRequest method.  Given most people will only issue tokens for the set up API key and we treat API keys as opaque (i.e. key ID is not really relevant), I recommend we change the [createTokenRequest](https://github.com/ably/ably-js/blob/master/common/lib/client/auth.js#L297-L326) in the JS client library so that:\r\n\r\n* Passing in an empty hash is valid so long as Basic Auth is being used\r\n* instead of key_id & key_value options in the hash, we should really just support a key option."},"comment":{"url":"https://api.github.com/repos/ably/ably-js/issues/comments/85716706","html_url":"https://github.com/ably/ably-js/issues/21#issuecomment-85716706","issue_url":"https://api.github.com/repos/ably/ably-js/issues/21","id":85716706,"user":{"login":"mattheworiordan","id":43789,"avatar_url":"https://avatars.githubusercontent.com/u/43789?v=3","gravatar_id":"","url":"https://api.github.com/users/mattheworiordan","html_url":"https://github.com/mattheworiordan","followers_url":"https://api.github.com/users/mattheworiordan/followers","following_url":"https://api.github.com/users/mattheworiordan/following{/other_user}","gists_url":"https://api.github.com/users/mattheworiordan/gists{/gist_id}","starred_url":"https://api.github.com/users/mattheworiordan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattheworiordan/subscriptions","organizations_url":"https://api.github.com/users/mattheworiordan/orgs","repos_url":"https://api.github.com/users/mattheworiordan/repos","events_url":"https://api.github.com/users/mattheworiordan/events{/privacy}","received_events_url":"https://api.github.com/users/mattheworiordan/received_events","type":"User","site_admin":false},"created_at":"2015-03-24T22:19:21Z","updated_at":"2015-03-24T22:19:21Z","body":"One more issue, the token request Hash that is returned has a Hash object for the capability element, but it should be a Stringified JSON object.  I believe if you receive a JSON capability the client library should be default Stringify it.  Example request:\r\n\r\n```javascript\r\nnew Ably.Realtime({ key: apiKey }).auth.createTokenRequest(\r\n        { keyId: keyId, keyValue: keyValue },\r\n        { \"ttl\": 600, \"capability\": { \"*\":[\"*\"] } }, function(token) {\r\n          console.log(token);\r\n        )\r\n\r\n'{\r\n  \"id\": \"xVLyHw.lwnKYQ\",\r\n  \"ttl\": 600,\r\n  \"capability\": {\r\n    \"*\": [\r\n      \"*\"\r\n    ]\r\n  },\r\n  \"timestamp\": 1427235284,\r\n  \"nonce\": \"0452151051722466\",\r\n  \"mac\": \"XslUpDsA5OQ7PSMKcrdb3IpMXNJg5VPXMyjVAgwsKyc=\"\r\n}'\r\n```"}}