Azure / Azure/azure-cli

Azure CLI fails with `400 Bad Request` in Cloud Shell for non-supported resource

Open
#11,386 4 comments 0 reactions 2 assignees Claimed by @evelyn-ys View on GitHub
Account act-codegen-extensibility-squad act-identity-squad Cloud Shell common issue Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

## Summary
When trying to obtain a token for the Azure API for FHIR using Azure CLI the following error appears:

**Command Name**
`az account get-access-token`

**Errors:**
```
400 Client Error: Bad Request for url: http://localhost:50342/oauth2/token
Traceback (most recent call last):
python3.6/site-packages/knack/cli.py, ln 206, in invoke
cmd_result = self.invocation.execute(args)
cli/core/commands/__init__.py, ln 603, in execute
raise ex
cli/core/commands/__init__.py, ln 661, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
...
python3.6/site-packages/msrestazure/azure_active_directory.py, ln 486, in get_msi_token
result.raise_for_status()
python3.6/site-packages/requests/models.py, ln 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://localhost:50342/oauth2/token
```

## To Reproduce:
Open Azure CLI from Azure Portal or sign in with [https://shell.azure.com](url)
Execute following command in CLI:
`token=$(az account get-access-token --resource=https://azurehealthcareapis.com | jq -r .accessToken)`

## Expected Behavior
Save access token in the variable named token for further use. The next step according to the documentation [https://docs.microsoft.com/en-us/azure/healthcare-apis/get-healthcare-apis-access-token-cli](url) is:
`curl -X GET --header "Authorization: Bearer $token" https://.azurehealthcareapis.com/Patient`

## Environment Summary
```
Linux-4.15.0-1063-azure-x86_64-with-debian-stretch-sid
Python 3.6.5
Shell: bash
azure-cli 2.0.77
Extensions:
healthcareapis 0.1.2
```

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.