class ActiveStorage::Service::GCSService

def issuer

def issuer
  @issuer ||= if @config[:gsa_email]
    @config[:gsa_email]
  else
    uri = URI.parse("http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/email")
    http = Net::HTTP.new(uri.host, uri.port)
    request = Net::HTTP::Get.new(uri.request_uri)
    request["Metadata-Flavor"] = "Google"
    begin
      response = http.request(request)
    rescue SocketError
      raise MetadataServerNotFoundError
    end
    if response.is_a?(Net::HTTPSuccess)
      response.body
    else
      raise MetadataServerError
    end
  end
end