Rails, where to store JSON credentials of Google C

2019-08-06 19:30发布

In my Google Developer Console, I have downloaded credentials json file. It looks like this:

client_secret-000000000-aaaaaaaaaa0a.apps.googleusercontent.json

I want to use google-api-client for ruby. In what folder do I need to place this json file? Also, how can I access it? All tutorials about this just skips it.

1条回答
Melony?
2楼-- · 2019-08-06 19:48

You may store it in any suitable directory, e. g. config (conventionally), lib, db etc.

To access it, use:

client = Google::APIClient.new(
  application_name: 'Your Google API Application',
  application_version: YOUR_VERSION
)
client.authorization = 
Google::APIClient::ClientSecrets.load(
  File.join(
    Rails.root,
    'config',
    'client_secret-000000000-aaaaaaaaaa0a.apps.googleusercontent.json'
  )
).to_authorization
查看更多
登录 后发表回答