{"action":"created","issue":{"url":"https://api.github.com/repos/lynndylanhurley/devise_token_auth/issues/568","repository_url":"https://api.github.com/repos/lynndylanhurley/devise_token_auth","labels_url":"https://api.github.com/repos/lynndylanhurley/devise_token_auth/issues/568/labels{/name}","comments_url":"https://api.github.com/repos/lynndylanhurley/devise_token_auth/issues/568/comments","events_url":"https://api.github.com/repos/lynndylanhurley/devise_token_auth/issues/568/events","html_url":"https://github.com/lynndylanhurley/devise_token_auth/issues/568","id":139876021,"number":568,"title":"Response headers do not include access-token unless we sleep for a few seconds","user":{"login":"ingolfured","id":1446817,"avatar_url":"https://avatars.githubusercontent.com/u/1446817?v=3","gravatar_id":"","url":"https://api.github.com/users/ingolfured","html_url":"https://github.com/ingolfured","followers_url":"https://api.github.com/users/ingolfured/followers","following_url":"https://api.github.com/users/ingolfured/following{/other_user}","gists_url":"https://api.github.com/users/ingolfured/gists{/gist_id}","starred_url":"https://api.github.com/users/ingolfured/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ingolfured/subscriptions","organizations_url":"https://api.github.com/users/ingolfured/orgs","repos_url":"https://api.github.com/users/ingolfured/repos","events_url":"https://api.github.com/users/ingolfured/events{/privacy}","received_events_url":"https://api.github.com/users/ingolfured/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-03-10T12:45:12Z","updated_at":"2016-04-01T18:49:31Z","closed_at":null,"body":"I have the following code, simply sends an call to the `auth/sign_in`, waits for 6 seconds and then uses the credential received to get a zip-file and a new `access-token` (from the headers)\r\n\r\n```ruby\r\ndef get_zip pid, path, token_info=nil, authentication=nil\r\n  if token_info.nil? || (Time.now.to_i > (token_info['expiry'].to_i - 10))\r\n    sign_in_uri = URI('https://urlPath.com/api/v1/auth/sign_in')\r\n    token_info = Net::HTTP.post_form(sign_in_uri,\r\n                                     'email':authentication[:email],\r\n                                     'password':authentication[:password]).\r\n    to_hash.map{|key,value| [key,value.first] }.\r\n    select{ |type,value| ['access-token','client','uid','expiry'].include?(type) }.to_h\r\n  end \r\n\r\n  sleep(6)\r\n  zip_url = URI(\"https://urlPath.com/api/v1/zips/#{pid}\")\r\n  zip_response = HTTParty.get(zip_url, headers: token_info)\r\n  File.write(path, zip_response.read_body.force_encoding('UTF-8'))\r\n  return zip_response.to_hash.\r\n    map{|key,value| [key,value.first] }.\r\n    select{ |type,value| ['access-token','client','uid','expiry'].include?(type) }.to_h\r\nend\r\n```\r\n\r\nThe problem is, this function returns the empty hash (`zip_response` doesn't have any `access-token` or other headers) UNLESS I have the line:\r\n```ruby \r\nsleep(6)\r\n```\r\n Is that normal? Any ideas?"},"comment":{"url":"https://api.github.com/repos/lynndylanhurley/devise_token_auth/issues/comments/204518778","html_url":"https://github.com/lynndylanhurley/devise_token_auth/issues/568#issuecomment-204518778","issue_url":"https://api.github.com/repos/lynndylanhurley/devise_token_auth/issues/568","id":204518778,"user":{"login":"kaevee","id":186616,"avatar_url":"https://avatars.githubusercontent.com/u/186616?v=3","gravatar_id":"","url":"https://api.github.com/users/kaevee","html_url":"https://github.com/kaevee","followers_url":"https://api.github.com/users/kaevee/followers","following_url":"https://api.github.com/users/kaevee/following{/other_user}","gists_url":"https://api.github.com/users/kaevee/gists{/gist_id}","starred_url":"https://api.github.com/users/kaevee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaevee/subscriptions","organizations_url":"https://api.github.com/users/kaevee/orgs","repos_url":"https://api.github.com/users/kaevee/repos","events_url":"https://api.github.com/users/kaevee/events{/privacy}","received_events_url":"https://api.github.com/users/kaevee/received_events","type":"User","site_admin":false},"created_at":"2016-04-01T18:49:31Z","updated_at":"2016-04-01T18:49:31Z","body":"Is there any resolution to missing access-token from headers?"}}