@@ -101,13 +101,6 @@ def _define_flags(parser):
101101 choices = ('local' , 'ssl' , 'ssl_dev' ),
102102 help = 'The type of credentials to use for the gRPC client' )
103103
104- parser .add_argument (
105- '--auth_type' ,
106- type = str ,
107- default = 'user' ,
108- choices = ('adc' , 'user' , 'none' ),
109- help = 'The type of auth credentials to obtain and add to requests.' )
110-
111104 parser .add_argument (
112105 '--auth_force_console' ,
113106 action = 'store_true' ,
@@ -201,6 +194,15 @@ def _run(flags):
201194 sys .stderr .write ('Logged out of uploader.\n ' )
202195 sys .stderr .flush ()
203196 return
197+ # TODO(b/141723268): maybe reconfirm Google Account prior to reuse.
198+ credentials = store .read_credentials ()
199+ if not credentials :
200+ _prompt_for_user_ack (intent )
201+ client_config = json .loads (auth .OAUTH_CLIENT_CONFIG )
202+ flow = auth .build_installed_app_flow (client_config )
203+ credentials = flow .run (force_console = flags .auth_force_console )
204+ sys .stderr .write ('\n ' ) # Extra newline after auth flow messages.
205+ store .write_credentials (credentials )
204206
205207 channel_options = None
206208 if flags .grpc_creds_type == 'local' :
@@ -214,27 +216,13 @@ def _run(flags):
214216 msg = 'Invalid --grpc_creds_type %s' % flags .grpc_creds_type
215217 raise base_plugin .FlagsError (msg )
216218
217- if flags .auth_type != 'none' :
218- if flags .auth_type == 'user' :
219- # TODO(b/141723268): determine if we should reconfirm the intended Google
220- # Account used for uploading prior to reusing the stored credentials.
221- credentials = store .read_credentials ()
222- if not credentials :
223- _prompt_for_user_ack (intent )
224- client_config = json .loads (dev_creds .DEV_OAUTH_CLIENT_CONFIG )
225- flow = auth .build_installed_app_flow (client_config )
226- credentials = flow .run (force_console = flags .auth_force_console )
227- sys .stderr .write ('\n ' ) # Extra newline after auth flow messages.
228- store .write_credentials (credentials )
229- elif flags .auth_type == 'adc' :
230- credentials = auth .application_default_credentials ()
231- channel_creds = grpc .composite_channel_credentials (
232- channel_creds , auth .id_token_call_credentials (credentials ))
219+ composite_channel_creds = grpc .composite_channel_credentials (
220+ channel_creds , auth .id_token_call_credentials (credentials ))
233221
234222 # TODO(@nfelt): In the `_UploadIntent` case, consider waiting until
235223 # logdir exists to open channel.
236224 channel = grpc .secure_channel (
237- flags .endpoint , channel_creds , options = channel_options )
225+ flags .endpoint , composite_channel_creds , options = channel_options )
238226 with channel :
239227 intent .execute (channel )
240228
0 commit comments