Closed arslanmurtaza closed 4 years ago
@arslanmurtaza Hi and thanks for opening this issue!
It appears that the documentation showing the use of configure
in AUTHENTICATION is incorrect for purely generated libraries. google-cloud-error_reporting
, google-cloud-error_reporting
and google-cloud-error_reporting
all have a manually-written layer that exposes settings via configure
, but google-cloud-monitoring
is purely generated and does not. I'll open a separate issue to fix the documentation.
Meanwhile, I'd like to help you get past your authentication issue. Is there a reason why you can't use environment variables to set your credentials, as correctly shown in the first two sections of AUTHENTICATION and below? Then you can create monitoring clients with no arguments, and the credentials will be discovered automatically:
export MONITORING_CREDENTIALS=/path/to/json
or for all APIs:
export GOOGLE_CLOUD_CREDENTIALS =/path/to/json
irb(main):001:0> require "google/cloud/monitoring"
=> true
irb(main):002:0> client = Google::Cloud::Monitoring::ServiceMonitoring.new
irb(main):003:0> client
=> #<Google::Cloud::Monitoring::V3::ServiceMonitoringServiceClient:0x00007fec1aa116d0
@quartzmo I actually tried that too, It was giving me the below error:
RuntimeError (Could not load the default credentials. Browse to)
https://developers.google.com/accounts/docs/application-default-credentials
for more information
Complete trace is
➜ ~ export MONITORING_CREDENTIALS="~/Downloads/my-keyfile.json"
➜ ~ irb
2.6.5 :001 > require "google/cloud/monitoring"
=> true
2.6.5 :002 > client = Google::Cloud::Monitoring::ServiceMonitoring.new
Traceback (most recent call last):
11: from /Users/arslanmurtaza/.rvm/rubies/ruby-2.6.5/bin/irb:23:in `<main>'
10: from /Users/arslanmurtaza/.rvm/rubies/ruby-2.6.5/bin/irb:23:in `load'
9: from /Users/arslanmurtaza/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
8: from (irb):2
7: from /Users/arslanmurtaza/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/google-cloud-monitoring-0.34.2/lib/google/cloud/monitoring.rb:416:in `new'
6: from /Users/arslanmurtaza/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/google-cloud-monitoring-0.34.2/lib/google/cloud/monitoring/v3.rb:455:in `new'
5: from /Users/arslanmurtaza/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/google-cloud-monitoring-0.34.2/lib/google/cloud/monitoring/v3.rb:455:in `new'
4: from /Users/arslanmurtaza/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/google-cloud-monitoring-0.34.2/lib/google/cloud/monitoring/v3/service_monitoring_service_client.rb:182:in `initialize'
3: from /Users/arslanmurtaza/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/googleauth-0.10.0/lib/googleauth/credentials.rb:295:in `default'
2: from /Users/arslanmurtaza/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/googleauth-0.10.0/lib/googleauth/credentials.rb:326:in `from_application_default'
1: from /Users/arslanmurtaza/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/googleauth-0.10.0/lib/googleauth/application_default.rb:76:in `get_application_default'
RuntimeError (Could not load the default credentials. Browse to)
https://developers.google.com/accounts/docs/application-default-credentials
for more information
Also I need to keep the configuration consistent if possible.
Can you try export MONITORING_CREDENTIALS=/Users/arslanmurtaza/Downloads/my-keyfile.json
instead of export MONITORING_CREDENTIALS="~/Downloads/my-keyfile.json"
?
And if that doesn't work, try moving my-keyfile.json
to your home dir and use: export MONITORING_CREDENTIALS=/Users/arslanmurtaza/my-keyfile.json
? (I think maybe by default OS X Terminal no longer allows access to Downloads
?)
Ah right, that worked.
export MONITORING_CREDENTIALS=/Users/arslanmurtaza/Downloads/my-keyfile.json
It was the Mac OS Catalina which was not letting the terminal read the credentials. Thanks alot.
Environment details
Steps to reproduce
Code example
Full backtrace
I'm using the Stackdriver logging, Bigquery and error reporting too. Those are working correctly with the following configuration
I tried with
too but that also gives the error like:
Any help will be greatly appreciated. Thanks!