title: store data in the client after devise authentication
body: <p>in my rails app, after successfully logging in with devise, I want to call an external service which returns a token. How can I pass it to the client in order it to be persisted (for example in localStorage)?</p>
  
  <pre><code>class Users::SessionsController &lt; Devise::SessionsController
    def create
      super
      login_to_chat #successful login
    end
  
    def login_to_chat
      uri = URI('https://xxxxxx.ws/authenticate')
  
      https = Net::HTTP.new(uri.host,uri.port)
      https.use_ssl = true
  
      req = Net::HTTP::Post.new(uri)
      req['Content-Type'] = 'application/json'
      req.body = params[:user].slice(:username,:password).to_json
  
      res = https.request(req)
  
      if res.kind_of? Net::HTTPSuccess
        json = JSON.parse(res.body)
  
        # how can I pass json['public_token'] to the client?
  
      end
    end
  end
  </code></pre>