首页 > 解决方案 > 如何在没有任何授权令牌的情况下使用 Azure API for FHIR Server

问题描述

我为Azure API for FHIR Server创建了一个资源。我可以使用https://fhir-server-url/metadata之类的 URL 查看元数据信息。如文档https://docs.microsoft.com/en-us/azure/healthcare-apis/access-fhir-postman-tutorial中所述访问其他 URL,如https://fhir-server-url/Patient,我们需要先获取授权令牌。要获取授权令牌,我们需要 ClientID,我们可以通过在 Azure Active Directory 中创建应用程序来获取它。但我无权访问它。

有什么方法可以在不需要授权令牌的情况下访问此 URL?通过在 Azure 门户中进行一些设置。

标签: azurehl7-fhirfhir-server-for-azure

解决方案


如果您使用第一方受众(例如https://azurehealthcareapis),这是为 FHIR 部署 Azure API 时的默认设置,您实际上可以使用第一方客户端应用程序(例如 Azure CLI)来获取令牌。检查https://docs.microsoft.com/azure/healthcare-apis/get-healthcare-apis-access-token-cli了解详细信息。

首先使用 Azure CLI ( https://docs.microsoft.com/cli/azure/?view=azure-cli-latest ) 登录:

az login

获取令牌并存储它

token=$(az account get-access-token --resource=https://azurehealthcareapis.com | jq -r .accessToken)

使用令牌:

curl -X GET --header "Authorization: Bearer $token" https://<FHIR ACCOUNT NAME>.azurehealthcareapis.com/Patient

推荐阅读