[英]403 - Authorization Error - OAuth2.0 - Access Token - Azure Api For Fhir
[英]How to use Azure API for FHIR Server without any authorization token
我为 FHIR Server 的 Azure API创建了一个资源。 我可以使用像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 门户中进行一些设置。
如果您使用第一方受众(例如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
从 FHIR Server Doc 看来,您可以根据FhirServer:Security:Enabled配置设置打开或关闭此功能,请参阅https://github.com/microsoft/fhir-server/blob/master/docs/Authentication.md
"FhirServer" : {
"Security": {
"Enabled": true,
"Authentication": {
"Audience": "fhir-api",
"Authority": "https://localhost:44348"
}
}}
一种方法是在 Azure Active Directory (AAD) 中注册您的应用程序。
您需要在 AAD 中注册两个应用程序才能获取客户端 ID 和客户端密钥以检索授权令牌。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.