{"action":"created","issue":{"url":"https://api.github.com/repos/onaio/milia/issues/45","labels_url":"https://api.github.com/repos/onaio/milia/issues/45/labels{/name}","comments_url":"https://api.github.com/repos/onaio/milia/issues/45/comments","events_url":"https://api.github.com/repos/onaio/milia/issues/45/events","html_url":"https://github.com/onaio/milia/issues/45","id":96571706,"number":45,"title":"Refactor Zebra API calls to refresh TempToken instead of reloading page","user":{"login":"pld","id":50706,"avatar_url":"https://avatars.githubusercontent.com/u/50706?v=3","gravatar_id":"","url":"https://api.github.com/users/pld","html_url":"https://github.com/pld","followers_url":"https://api.github.com/users/pld/followers","following_url":"https://api.github.com/users/pld/following{/other_user}","gists_url":"https://api.github.com/users/pld/gists{/gist_id}","starred_url":"https://api.github.com/users/pld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pld/subscriptions","organizations_url":"https://api.github.com/users/pld/orgs","repos_url":"https://api.github.com/users/pld/repos","events_url":"https://api.github.com/users/pld/events{/privacy}","received_events_url":"https://api.github.com/users/pld/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/onaio/milia/labels/High%20Priority","name":"High Priority","color":"5319e7"},{"url":"https://api.github.com/repos/onaio/milia/labels/SIZE%20-%20Medium%20(2-3)","name":"SIZE - Medium (2-3)","color":"000000"}],"state":"open","locked":false,"assignee":{"login":"geoffreymuchai","id":765152,"avatar_url":"https://avatars.githubusercontent.com/u/765152?v=3","gravatar_id":"","url":"https://api.github.com/users/geoffreymuchai","html_url":"https://github.com/geoffreymuchai","followers_url":"https://api.github.com/users/geoffreymuchai/followers","following_url":"https://api.github.com/users/geoffreymuchai/following{/other_user}","gists_url":"https://api.github.com/users/geoffreymuchai/gists{/gist_id}","starred_url":"https://api.github.com/users/geoffreymuchai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geoffreymuchai/subscriptions","organizations_url":"https://api.github.com/users/geoffreymuchai/orgs","repos_url":"https://api.github.com/users/geoffreymuchai/repos","events_url":"https://api.github.com/users/geoffreymuchai/events{/privacy}","received_events_url":"https://api.github.com/users/geoffreymuchai/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2015-07-22T13:42:50Z","updated_at":"2015-07-23T04:07:56Z","closed_at":null,"body":"Problem:\r\n\r\nWhen the temp token expires there will be an auth failure in the cljs and the page will reload. This is unnecessary and disruptive to the user, suppose they have models open, or are scrolled to a specific part of the page, or have created temporary items.\r\n\r\nSolution:\r\n\r\n* add a `credentials` atom to milia\r\n * store a `refresh-url` in it, this is a path on the `:ui` server that will return an updated temp token\r\n * store the `auth-token` in it\r\n\r\nWhen there is an auth failure in the cljs\r\n* make a request to the `refresh-url` to authenticate with the session and retrieve a refreshed temporary token\r\n * that is to say, do work equivalent to `validate-token`\r\n* update the `auth-token` with the new token\r\n* redo the request that failed\r\n * **CLJS** if it fails again, then give up and do a page reload"},"comment":{"url":"https://api.github.com/repos/onaio/milia/issues/comments/123957816","html_url":"https://github.com/onaio/milia/issues/45#issuecomment-123957816","issue_url":"https://api.github.com/repos/onaio/milia/issues/45","id":123957816,"user":{"login":"pld","id":50706,"avatar_url":"https://avatars.githubusercontent.com/u/50706?v=3","gravatar_id":"","url":"https://api.github.com/users/pld","html_url":"https://github.com/pld","followers_url":"https://api.github.com/users/pld/followers","following_url":"https://api.github.com/users/pld/following{/other_user}","gists_url":"https://api.github.com/users/pld/gists{/gist_id}","starred_url":"https://api.github.com/users/pld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pld/subscriptions","organizations_url":"https://api.github.com/users/pld/orgs","repos_url":"https://api.github.com/users/pld/repos","events_url":"https://api.github.com/users/pld/events{/privacy}","received_events_url":"https://api.github.com/users/pld/received_events","type":"User","site_admin":false},"created_at":"2015-07-23T04:07:56Z","updated_at":"2015-07-23T04:07:56Z","body":"See the readme for the approach:\r\n\r\n* all the `account` vars are being removed, the `io` namespaces will refer to `*credentials*`\r\n* credentials are stored as a dynamic atom, we use earmuffs are call it *credentials* to show that it is dynamic, as is standard\r\n * we can use `binding` to rebind it for when we need to alter the state for a specific API call\r\n* `parse-http` now takes, `method`, `url`, and a list options to be destructured as args\r\n\r\nnote that the tests are passing but only a small portion has been converted, the rest needs to be converted to remove `account`\r\n\r\nI also have not touched `io.cljs` yet, it should be able to follow the same pattern as `io.clj`"}}