How can I authorize a Google Service Account without the default credentials file?

前端 未结 3 1787
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-04 12:20

I have a Google Service Account that my app uses to retrieve data from Google Analytics.

When I created the account I downloaded a client_secrets file with

3条回答
  •  灰色年华
    2021-02-04 12:52

    I found this

    require "google/cloud/bigquery"
    
    ENV["BIGQUERY_PROJECT"]     = "my-project-id"
    ENV["BIGQUERY_CREDENTIALS"] = "path/to/keyfile.json"
    
    bigquery = Google::Cloud::Bigquery.new
    

    more detail:

    https://github.com/googleapis/google-cloud-ruby/blob/master/google-cloud-bigquery/AUTHENTICATION.md

提交回复
热议问题