@@ -54,13 +54,16 @@ class APIClient
54
54
# <li><code>:two_legged_oauth_1</code></li>
55
55
# <li><code>:oauth_1</code></li>
56
56
# <li><code>:oauth_2</code></li>
57
+ # <li><code>:google_app_default</code></li>
57
58
# </ul>
58
59
# @option options [Boolean] :auto_refresh_token (true)
59
60
# The setting that controls whether or not the api client attempts to
60
61
# refresh authorization when a 401 is hit in #execute. If the token does
61
62
# not support it, this option is ignored.
62
63
# @option options [String] :application_name
63
64
# The name of the application using the client.
65
+ # @option options [String | Array | nil] :scope
66
+ # The scope(s) used when using google application default credentials
64
67
# @option options [String] :application_version
65
68
# The version number of the application using the client.
66
69
# @option options [String] :user_agent
@@ -114,6 +117,9 @@ def initialize(options={})
114
117
# default authentication mechanisms.
115
118
self . authorization =
116
119
options . key? ( :authorization ) ? options [ :authorization ] : :oauth_2
120
+ if !options [ 'scope' ] . nil? and self . authorization . respond_to? ( :scope= )
121
+ self . authorization . scope = options [ 'scope' ]
122
+ end
117
123
self . auto_refresh_token = options . fetch ( :auto_refresh_token ) { true }
118
124
self . key = options [ :key ]
119
125
self . user_ip = options [ :user_ip ]
@@ -174,6 +180,10 @@ def authorization=(new_authorization)
174
180
:client_credential_secret => nil ,
175
181
:two_legged => true
176
182
)
183
+ when :google_app_default
184
+ require 'googleauth'
185
+ new_authorization = Google ::Auth . get_application_default ( nil )
186
+
177
187
when :oauth_2
178
188
require 'signet/oauth_2/client'
179
189
# NOTE: Do not rely on this default value, as it may change
0 commit comments