{"action":"created","issue":{"url":"https://api.github.com/repos/joshuef/safe-js/issues/9","repository_url":"https://api.github.com/repos/joshuef/safe-js","labels_url":"https://api.github.com/repos/joshuef/safe-js/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/joshuef/safe-js/issues/9/comments","events_url":"https://api.github.com/repos/joshuef/safe-js/issues/9/events","html_url":"https://github.com/joshuef/safe-js/issues/9","id":183281533,"number":9,"title":"window.safeAuth.authorise() in beaker doesn't return a token","user":{"login":"theWebalyst","id":2183895,"avatar_url":"https://avatars.githubusercontent.com/u/2183895?v=3","gravatar_id":"","url":"https://api.github.com/users/theWebalyst","html_url":"https://github.com/theWebalyst","followers_url":"https://api.github.com/users/theWebalyst/followers","following_url":"https://api.github.com/users/theWebalyst/following{/other_user}","gists_url":"https://api.github.com/users/theWebalyst/gists{/gist_id}","starred_url":"https://api.github.com/users/theWebalyst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theWebalyst/subscriptions","organizations_url":"https://api.github.com/users/theWebalyst/orgs","repos_url":"https://api.github.com/users/theWebalyst/repos","events_url":"https://api.github.com/users/theWebalyst/events{/privacy}","received_events_url":"https://api.github.com/users/theWebalyst/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-10-16T18:16:16Z","updated_at":"2016-10-17T19:24:18Z","closed_at":"2016-10-17T19:24:18Z","body":"I have had some success authorising with beaker/safe-js but it seems easy for me to get into a state where ```window.safeAuth.authorise(...).then( function (res) {...} )``` succeeds, but fails to return a token:\r\n\r\nI see\r\n```res.checkedOut``` is true\r\nbut\r\n```res.token``` is undefined\r\n\r\nAm I right in thinking that if ```res.checkedOut``` is true, ```res.token``` can be expected to be defined (and valid)? If so I guess that's a safe-js bug?\r\n\r\nHopefully if this is a safe-js bug you can diagnose and fix just by inspecting the code. If not you might be able to reproduce it by using my safe://myfd.rsports app on Test10.\r\n\r\n### How To Reproduce\r\nAssuming a safe-js bug I'm not sure how to reproduce it but think that it might be once the token has been obtained and is available in localStorage that this can happen. What I'm doing is reloading my safe://myfd.rsports app (Test 10) so you could try to reproduce with that and see the result within     ```safenetworkAuthorize: function (appApiKeys) {...}``` in remotestorage.js as follows:\r\n\r\nStart SAFE Launcher and login to Test10 network\r\nStart beaker, open beaker dev tools and visit safe://myfd.rsports\r\nWatch the console\r\nCreate a drink in the app\r\nclick the blue icon top right, authorise in Launcher\r\n\r\nWatch the console for it working, which is indicated by it trying to sync with safe storage every 10s. If it is working there will be a burst of output every ten seconds although the code is failing, the sync will continue. Unfortunately this condition won't show the undefined token bug reported above. So you'll have to find a way to get to the state where the token is not returned.\r\n\r\nIf it is not syncing every 10s. This is normal (but a bug in the app), but you can usually trigger it by Ctrl-Shift-R the App and also clicking on the SAFE icon (top right) to try and get it to connect.\r\n\r\nCorrect sync means you won't be seeing the undefined token bug.\r\nFailing to try and sync may still mean you won't see this bug.\r\n\r\nThe question is how to get from either of the above two states to the third state where there is no sync happening and each click on the SAFE icon results in ```window.safeAuth.authorise(...)``` to return ```res.token``` undefined while ```res.checkedOut``` is true (all the time at the moment). That, I'm not sure.\r\n\r\nProbably irrelevant, but I am using a custom build of beaker where I have changed nfs.js ```getDir()```:\r\n```\r\nreturn response\r\n```\r\nto\r\n```\r\nreturn parseResponse(response);\r\n```\r\nin order to fix issue https://github.com/joshuef/safe-js/issues/7"},"comment":{"url":"https://api.github.com/repos/joshuef/safe-js/issues/comments/254306993","html_url":"https://github.com/joshuef/safe-js/issues/9#issuecomment-254306993","issue_url":"https://api.github.com/repos/joshuef/safe-js/issues/9","id":254306993,"user":{"login":"theWebalyst","id":2183895,"avatar_url":"https://avatars.githubusercontent.com/u/2183895?v=3","gravatar_id":"","url":"https://api.github.com/users/theWebalyst","html_url":"https://github.com/theWebalyst","followers_url":"https://api.github.com/users/theWebalyst/followers","following_url":"https://api.github.com/users/theWebalyst/following{/other_user}","gists_url":"https://api.github.com/users/theWebalyst/gists{/gist_id}","starred_url":"https://api.github.com/users/theWebalyst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theWebalyst/subscriptions","organizations_url":"https://api.github.com/users/theWebalyst/orgs","repos_url":"https://api.github.com/users/theWebalyst/repos","events_url":"https://api.github.com/users/theWebalyst/events{/privacy}","received_events_url":"https://api.github.com/users/theWebalyst/received_events","type":"User","site_admin":false},"created_at":"2016-10-17T19:24:18Z","updated_at":"2016-10-17T19:24:18Z","body":"Thanks Francis, that looks like it. I get something that looks like a token (but a lot longer than I'm used to!)\r\n\r\nBit of a clunky API don't you think? Also will need documenting. I'll close this though."}}
{"actor":{"display_login":"theWebalyst"}}