title: Authenticating a google.storage.Client without saving the service account JSON to disk
body: <p>For authentication of a Google Cloud Platform storage client, I'd like to NOT write the service account JSON (credentials file that you create) to disk. I would like to keep them purely in memory after loading them from a Hashicorp Vault keystore that is shared by all cloud instances. Is there a way to pass the JSON credentials directly, rather than passing a pathlike/file object?</p>
  
  <p>I understand how to do this using a pathlike/file object as follows, but this is what I want to avoid (due to security issues, I'd prefer to never write them to disk):</p>
  
  <pre class="lang-py prettyprint-override"><code>from google.cloud import storage
  
  # set an environment variable that relies on a JSON file
  export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service_account.json"
  
  # create the client (assumes the environment variable is set)
  client = storage.Client()
  
  # alternately, one can create the client without the environment 
  # variable, but this still relies on a JSON file.
  client = storage.Client.from_service_account_json("/path/to/service_account.json")
  </code></pre>
  
  <p>I have tried to get around this by referencing the JSON DATA (json_data) directly, but this throws the error: <code>TypeError: expected str, bytes or os.PathLike object, not dict</code></p>
  
  <pre class="lang-py prettyprint-override"><code>json_data = {....[JSON]....}
  client = storage.Client.from_service_account_json(json_data)
  </code></pre>
  
  <p>Also, dumping to JSON, but I get the error: </p>
  
  <p><code>with io.open(json_credentials_path, "r", encoding="utf-8") as json_fi:
  OSError: [Errno 63] File name too long: '{"type": "service_account", "project_id",......</code></p>
  
  <pre class="lang-py prettyprint-override"><code>json_data = {....[JSON]....}
  client = storage.Client.from_service_account_json(json.dumps(json_data))
  </code></pre>
  
  <p>Per the suggestion from @johnhanley, I have also tried:</p>
  
  <pre class="lang-py prettyprint-override"><code>from google.cloud import storage
  from google.oauth2 import service_account
  
  json_data = {...data loaded from keystore...}
  type(json_data)
     dict
  
  credentials = service_account.Credentials.from_service_account_info(json_data)
  type(credentials)
     google.oauth2.service_account.Credentials
  
  client = storage.Client(credentials=credentials)
  </code></pre>
  
  <p>This resulted in the DefaultCredentialsError:</p>
  
  <p><code>raise exceptions.DefaultCredentialsError(_HELP_MESSAGE)
  google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information, please see https://developers.google.com/accounts/docs/application-default-credentials.</code></p>
  
  <p>If you have ideas on how to solve this, I'd love to hear it!</p>