How to upload a json file with secret keys to Heroku : <p>I'm building a rails app that pulls data from Google Analytics using the Google Api Client Library for Ruby.</p>

<p>I'm using OAuth2 and can get everything working in development on a local machine. My issue is that the library uses a downloaded file, <code>client_secrets.json</code>,  to store two secret keys.</p>

<p><strong>Problem:I'm using Heroku and need a way to get the file to their production servers.</strong> </p>

<p>I don't want to add this file to my github repo as the project is public. </p>

<p>If there is a way to temporarily add the file to git, push to Heroku, and remove from git that would be fine. My sense is that the keys will be in the commits and very hard to prevent from showing on github. </p>

<p><strong>Tried:</strong>
As far I can tell you cannot SCP a file to Heroku via a Bash console. I believe when doing this you get a new Dyno and anything you add would be only be temporary. I tried this but couldn't get SCP to work properly, so not 100% sure about this.</p>

<p><strong>Tried:</strong>
I looked at storing the JSON file in an Environment or Config Var, but couldn't get it to work. This seems like the best way to go if anyone has a thought. I often run into trouble when ruby converts JSON into a string or hash, so possibly I just need guidance here. </p>

<p><strong>Tried:</strong>
Additionally I've tried to figure out a way to just pull out the keys from the JSON file, put them into Config Vars, and add the JSON file to git. I can't figure out a way to put <code>ENV["KEY"]</code> in a JSON file though. </p>

<hr>

<p><strong>Example Code</strong>
The <a href="https://developers.google.com/api-client-library/ruby/auth/web-app" rel="noreferrer">Google library has a method</a> that loads the JSON file to create an authorization client. The client then fetches a token (or gives a authorization url).</p>

<pre><code>client_secrets = Google::APIClient::ClientSecrets.load('client_secrets.json')
auth_client = client_secrets.to_authorization
</code></pre>

<p>** note that the example on google page doesn't show a filename because it uses a default ENV Var thats been set to a path</p>

<p>I figure this would all be a lot easier if the <code>ClientSecrets.load()</code> method would just take JSON, a string or a hash which could go into a Config Var. </p>

<p>Unfortunately it always seems to want a file path. When I feed it JSON, a string or hash, it blows up. <a href="http://ar.zu.my/how-to-store-private-key-files-in-heroku/" rel="noreferrer">I've seen someone get around the issue with a p12 key here</a>, but I'm not sure how to replicate that in my situation. </p>

<p><strong>Haven't Tried:</strong>
My only other though (aside from moving to AWS) is to put the JSON file on AWS and have rails pull it when needed. I'm not sure if this can be done on the fly or if the file would need to be pulled down when the rails server boots up. Seems like too much work, but at this point I've spend a few hours on it so ready to attempt. </p>

<p>This is the specific controller I am working on:
<a href="https://github.com/dladowitz/slapafy/blob/master/app/controllers/welcome_controller.rb" rel="noreferrer">https://github.com/dladowitz/slapafy/blob/master/app/controllers/welcome_controller.rb</a></p>
