def ensure_csrf(klass)
      if csrf_cache[klass]
        self.csrf_tokens = csrf_cache[klass]
        return
      end

      self.csrf_tokens = nil

      # If we directly create a new resource (e.g. app) without querying anything before
      # we don't have a valid csrf token, that's why we have to do at least one request
      block_given? ? yield : klass.all

      csrf_cache[klass] = self.csrf_tokens
    end
def ensure_csrf(klass)
      if csrf_cache[klass]
        self.csrf_tokens = csrf_cache[klass]
        return
      end

      self.csrf_tokens = nil

      # If we directly create a new resource (e.g. app) without querying anything before
      # we don't have a valid csrf token, that's why we have to do at least one request
      block_given? ? yield : klass.all

      csrf_cache[klass] = self.csrf_tokens
    end
Ensures that there are csrf tokens for the appropriate entity type
 Relies on store_csrf_tokens to set csrf_tokens to the appropriate value
 then stores that in the correct place in cache
 This method also takes a block, if you want to send a custom request, instead of
 calling `.all` on the given klass. This is used for provisioning profiles.