How to create a link service in Azure Data Factory for Rest API which has OAuth grant type as password type of authentication

Kukade, Atharva 0 Reputation points
2024-12-20T12:27:29.0933333+00:00

We need to call Rest API which has OAuth grant type as password type of authentication in a loop to store response in CSV. I know we could use Copy Activity but we are unable to create link service with mentioned authentication.

We tried to do simple web call in a loop and append response in variable and then copy variable to file. However in this case variable exceeds size.

Any help is appreciated.

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

1 answer

Sort by: Most helpful
  1. phemanth 12,575 Reputation points Microsoft Vendor
    2024-12-20T17:26:41.1433333+00:00

    @Kukade, Atharva

    Thanks for the question and using MS Q&A platform.

    To create a linked service in Azure Data Factory for a REST API with OAuth password grant type authentication, you can follow these steps:

    Create a Linked Service:

    • Go to your Azure Data Factory instance.
    • Navigate to the "Manage" tab and select "Linked Services".
    • Click on "New" and choose "REST" as the type of linked service.
    • Configure the linked service with the necessary details, including the base URL of your REST API.

    Select REST connector. Configure REST linked service.

    Configure OAuth Authentication:

    • In the linked service configuration, set the authenticationType to Basic.
    • Provide the username and password for the OAuth password grant type.

    Use Web Activity for Token Retrieval:

    Shows the UI for a Web activity.

    • Since Azure Data Factory does not natively support OAuth password grant type directly in the linked service, you can use a Web Activity to first retrieve the OAuth token.
    • Create a Web Activity to call the token endpoint of your OAuth server. This activity should include the necessary parameters (username, password, client_id, client_secret, etc.) to obtain the token.

    Pass Token to Copy Activity:

    • Use the output of the Web Activity to pass the token to subsequent activities.
    • In your Copy Activity, set the Authorization header to Bearer <token> using the token obtained from the Web Activity.

    Loop and Store Responses:

    • Use a ForEach activity to loop through your API calls.
    • Within the loop, use the Copy Activity to store the responses in a CSV file. Ensure you handle pagination or multiple API calls as needed.

    I hope the above steps will resolve the issue, please do let us know if issue persists. Thank you

    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.