title: Ruby on Rails Google Api Authentication
body: <p>So, I'm very new to this. I got a generated json file from my google developer console that holds information like private keys, client id, token stuff, etc.</p>
  
  <p>Now, I'm trying to use the Google Analytics Report V4 api. I put all my code into a concern, and when I run the code I get this error:</p>
  
  <pre><code>Google::Apis::AuthorizationError: Unauthorized
  </code></pre>
  
  <p>So I know that I have to authorize my app, but I'm not sure how. I have this json file which appears to have all the information I need to authenticate my app.</p>
  
  <p>After some research, I know that (on the following code) I need to assign analytics.authorization to something, I just don't know to what.</p>
  
  <pre><code>analytics = Google::Apis::AnalyticsreportingV4::AnalyticsReportingService.new
  analytics.authorization = ???
  </code></pre>
  
  <p>Do you know of any method I'm supposed to call that takes in the location of my json file as a parameter or something that can in turn, authorize my rails app?</p>
  
  <p>Thank you so so much if you can help.</p>
  
  <p>I know there are other questions like this. But they use omniauth with devise I think, and I can't do that. I already have a specific context in which users need to be logged in to my app, so logging in with google wouldn't work in my case. Also, other question/answers that don't involve omniauth and devise are outdated or don't have an accepted answer.</p>