how to create xero linked service in azure data factory(authenticationType=OAuth_2.0) using azure fluent library

chamith rasintha 0 Reputation points
2023-03-07T04:21:54.73+00:00

i had try to create xero linked service with oAuth 2.0 using different ways using c# API(using Microsoft.Azure.Management.Fluent;), but couldn't create that with oAuth 2.0

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,624 questions
Microsoft Security Microsoft Graph
{count} votes

1 answer

Sort by: Most helpful
  1. HimanshuSinha-msft 19,486 Reputation points Microsoft Employee Moderator
    2023-03-07T22:53:05.8733333+00:00

    Hello @chamith rasintha , Thanks for the question and using MS Q&A platform.

    To create a Xero linked service in Azure Data Factory with OAuth 2.0 authentication using Azure Fluent library, you can follow these steps:

    1. Add the necessary dependencies to your project. You will need the following NuGet packages:
      • Microsoft.Azure.Management.DataFactory.Fluent
      • Microsoft.Azure.Management.ResourceManager.Fluent
      • Microsoft.IdentityModel.Clients.ActiveDirectory
    2. Create an instance of the Azure class and authenticate to your Azure account using your credentials.
    var credentials = SdkContext.AzureCredentialsFactory
                             .FromServicePrincipal(clientId, clientSecret, tenantId, AzureEnvironment.AzureGlobalCloud);
    var azure = Azure.Authenticate(credentials).WithDefaultSubscription();
    
    

    Create a new Xero linked service using the DefineLinkedService() method of the DataFactory class. Set the AuthenticationType to OAuth2.

    var linkedService = azure.DataFactories
                             .DefineLinkedService("xeroLinkedService")
                             .WithType("Xero")
                             .WithDescription("Xero linked service")
                             .WithJsonDefinition(@"{
                                 ""type"": ""Xero"",
                                 ""typeProperties"": {
                                     ""authenticationType"": ""OAuth2"",
                                     ""clientId"": ""<your-client-id>"",
                                     ""clientSecret"": {
                                         ""type"": ""SecureString"",
                                         ""value"": ""<your-client-secret>""
                                     },
                                     ""authorizationEndpoint"": ""https://login.xero.com/identity/connect/authorize"",
                                     ""tokenEndpoint"": ""https://identity.xero.com/connect/token"",
                                     ""resource"": ""https://api.xero.com"",
                                     ""redirectUri"": ""urn:ietf:wg:oauth:2.0:oob:auto"",
                                     ""scope"": ""openid profile email accounting.contacts accounting.settings accounting.transactions offline_access""
                                 }
                             }")
                             .Create();
    
    

    Note: Replace <your-client-id> and <your-client-secret> with your Xero OAuth 2.0 client ID and secret.

    Use the Create() method to create the linked service in Azure Data Factory.

    linkedService.Create();

    That's it! You have now created a Xero linked service in Azure Data Factory with OAuth 2.0 authentication using Azure Fluent library.

    Thanks
    Himanshu

    Please accept as "Yes" if the answer provided is useful , so that you can help others in the community looking for remediation for similar issues. 

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.