Not able to access azure digital twin API without user interaction

196 Views Asked by At

I referred to these answers but I'm not able to authenticate Azure Digital Twins without browser interaction.

  1. How to access azure digital twin API using Service Principal?

  2. Is it possible to configure Azure Digital Twins API access for a Daemon App?

1

There are 1 best solutions below

0
On

Those two questions both refer to the Azure Digital Twins preview before it was refreshed. It is possible to access Azure Digital Twins without browser authentication. You will need the Azure.Identity package. I used version 1.2.2

var credential =
    new ClientSecretCredential("{AZURE_TENANT_ID}, "{AZURE_CLIENT_ID}", "{AZURE_CLIENT_SECRET}");
var client = new DigitalTwinsClient(new Uri("{AZURE_DIGITAL_TWINS_URL}"), credential);

You need to replace the values with

  1. Your Azure AD tenant ID.
  2. The client application ID of the app registration you created in Azure AD.
  3. A client secret, you need to create this in the app registration in the Certificates & Secrets blade.
  4. The URL to your Azure Digital Twins instance.