Azure / Azure/azure-cli

get-access-token failed

Open
#13,893 8 comments 0 reactions 1 assignee Assigned to @houk-ms View on GitHub
Account act-identity-squad Error Handling feature-request
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

> ### `az feedback` auto-generates most of the information requested below, as of CLI version 2.0.62

**Describe the bug**
It failed when getting access token:
`az account get-access-token --q accessToken -o tsv`
If it fails by design, is it possible to fail elegantly?

(**'Connection aborted.', OSError("(104, 'ECONNRESET')"**,))
Traceback (most recent call last):
File "/opt/az/lib/python3.6/site-packages/urllib3/connectionpool.py", line 603, in urlopen
chunked=chunked)
File "/opt/az/lib/python3.6/site-packages/urllib3/connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "", line 2, in raise_from
File "/opt/az/lib/python3.6/site-packages/urllib3/connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "/opt/az/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/opt/az/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/opt/az/lib/python3.6/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/opt/az/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
File "/opt/az/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 309, in recv_into
raise SocketError(str(e))
OSError: (104, 'ECONNRESET')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/az/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/opt/az/lib/python3.6/site-packages/urllib3/connectionpool.py", line 641, in urlopen
_stacktrace=sys.exc_info()[2])
File "/opt/az/lib/python3.6/site-packages/urllib3/util/retry.py", line 368, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/opt/az/lib/python3.6/site-packages/urllib3/packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/opt/az/lib/python3.6/site-packages/urllib3/connectionpool.py", line 603, in urlopen
chunked=chunked)
File "/opt/az/lib/python3.6/site-packages/urllib3/connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "", line 2, in raise_from
File "/opt/az/lib/python3.6/site-packages/urllib3/connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "/opt/az/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/opt/az/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/opt/az/lib/python3.6/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/opt/az/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
File "/opt/az/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 309, in recv_into
raise SocketError(str(e))
urllib3.exceptions.ProtocolError: ('Connection aborted.', OSError("(104, 'ECONNRESET')",))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 215, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 654, in execute
raise ex
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 718, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 711, in _run_job
six.reraise(*sys.exc_info())
File "/opt/az/lib/python3.6/site-packages/six.py", line 703, in reraise
raise value
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 688, in _run_job
result = cmd_copy(params)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 325, in __call__
return self.handler(*args, **kwargs)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 545, in default_command_handler
return op(**command_args)
File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/profile/custom.py", line 75, in get_access_token
creds, subscription, tenant = profile.get_raw_token(subscription=subscription, resource=resource, tenant=tenant)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/_profile.py", line 655, in get_raw_token
tenant_dest)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/_profile.py", line 1056, in retrieve_token_for_service_principal
token_entry = sp_auth.acquire_token(context, resource, sp_id)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/_profile.py", line 1156, in acquire_token
return authentication_context.acquire_token_with_client_credentials(resource, client_id, self.secret)
File "/opt/az/lib/python3.6/site-packages/adal/authentication_context.py", line 179, in acquire_token_with_client_credentials
return self._acquire_token(token_func)
File "/opt/az/lib/python3.6/site-packages/adal/authentication_context.py", line 128, in _acquire_token
return token_func(self)
File "/opt/az/lib/python3.6/site-packages/adal/authentication_context.py", line 177, in token_func
return token_request.get_token_with_client_credentials(client_secret)
File "/opt/az/lib/python3.6/site-packages/adal/token_request.py", line 310, in get_token_with_client_credentials
token = self._oauth_get_token(oauth_parameters)
File "/opt/az/lib/python3.6/site-packages/adal/token_request.py", line 112, in _oauth_get_token
return client.get_token(oauth_parameters)
File "/opt/az/lib/python3.6/site-packages/adal/oauth2_client.py", line 268, in get_token
timeout=self._call_context.get('timeout', None))
File "/opt/az/lib/python3.6/site-packages/requests/api.py", line 116, in post
return request('post', url, data=data, json=json, **kwargs)
File "/opt/az/lib/python3.6/site-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/opt/az/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/opt/az/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/opt/az/lib/python3.6/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', OSError("(104, 'ECONNRESET')",))
**To Reproduce**

**Expected behavior**

**Environment summary**

`az version` is 2.5.1
**Additional context**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.