Skip to content

Latest commit

 

History

History
69 lines (49 loc) · 3.34 KB

get-access-token.md

File metadata and controls

69 lines (49 loc) · 3.34 KB
title description services author ms.service ms.topic ms.date ms.author ms.custom ms.devlang
Get an access token to use the FHIR service or the DICOM service
Learn how to get an access token for the FHIR service or the DICOM service.
healthcare-apis
chachachachami
healthcare-apis
how-to
09/06/2023
chrupa
devx-track-azurepowershell, devx-track-azurecli
azurecli

Get an access token by using Azure CLI or Azure PowerShell

To use the FHIR® service or the DICOM® service, you need an access token that verifies your identity and permissions to the server. You can obtain an access token using PowerShell or the Azure Command-Line Interface (CLI), which are tools for creating and managing Azure resources.

Keep in mind that to access the FHIR service or the DICOM service, users and applications must be granted permissions through role assignments from Azure portal, or by using scripts.


Get an access token for the FHIR service

The FHIR service uses a specific resource or Audience with URI equal to the URI of the FHIR server https://<workspacename-fhirservicename>.fhir.azurehealthcareapis.com. Obtain a token and store it in a variable (named $token) with the following command:

token=$(az account get-access-token --resource=https://<workspacename-fhirservicename>.fhir.azurehealthcareapis.com --query accessToken --output tsv)
curl -X GET --header "Authorization: Bearer $token" https://<workspacename-fhirservicename>.fhir.azurehealthcareapis.com/Patient
$token = (Get-AzAccessToken -ResourceUrl 'https://<workspacename-fhirservicename>.fhir.azurehealthcareapis.com').Token
$headers = @{Authorization="Bearer $token"}
Invoke-WebRequest -Method GET -Headers $headers -Uri 'https://<workspacename-fhirservicename>.fhir.azurehealthcareapis.com/Patient'

Get an access token for the DICOM service

The DICOM service uses the same resource or Audience with URI equal to https://dicom.healthcareapis.azure.com to obtain an access token. Obtain a token and store it in a variable (named $token) with the following command:

token=$(az account get-access-token --resource=https://dicom.healthcareapis.azure.com --query accessToken --output tsv)
curl -X GET --header "Authorization: Bearer $token"  https://<workspacename-dicomservicename>.dicom.azurehealthcareapis.com/v<version of REST API>/changefeed
$token = (Get-AzAccessToken -ResourceUrl 'https://dicom.healthcareapis.azure.com').Token
$headers = @{Authorization="Bearer $token"}
Invoke-WebRequest -Method GET -Headers $headers -Uri 'https://<workspacename-dicomservicename>.dicom.azurehealthcareapis.com/v<version of REST API>/changefeed'

Next steps

Access the FHIR service by using Postman

Access the FHIR service by using REST client

Access the DICOM service by using cURL

[!INCLUDE FHIR and DICOM trademark statement]