Forum Discussion

hameed4ru's avatar
hameed4ru
Frequent Visitor
1 year ago
Solved

Unable to Configure API with Bearer token from DataFlow

I am working on one of the project where I need to configure the WebAPI in Azure Fabric through the Bearer Token Authentication. I tried writing the Python Script and tried adding the BearerToken fro...
  • v-veshwara-msft's avatar
    1 year ago

    Hi hameed4ru ,

    Thanks for posting in the Microsoft Fabric Community.

    To call an API with a Bearer Token from Dataflow Gen2, follow these steps:

    1. Open Dataflow Gen2 and select Blank Query under Get Data.
    2. Insert M query. 
      For instance here is an example query :
      let
      URL = "https://www.strava.com/api/v3/oauth/token",
      Headers = [#"Content-Type"="application/json"],
      Body = "{""client_id"": ""InsertYourClientIDHere"", ""client_secret"": ""InsertYourClientSecretHere"", ""grant_type"": ""refresh_token"", ""refresh_token"": ""InsertYourRefreshTokenHere""}",
      Source = Json.Document(Web.Contents(URL, [Headers = Headers, Content = Text.ToBinary(Body)])),
      #"Converted to table" = Record.ToTable(Source),
      #"Filtered rows" = Table.SelectRows(#"Converted to table", each ([Name] = "access_token")),
      #"Drill down" = #"Filtered rows"{0}[Value]
      in
      #"Drill down"

    This retrieves an access token, which you can use in subsequent API calls.

    Here are some similar discussions about API in Dataflow Gen2:
    Solved: Dataflows - Web API - authentication - Microsoft Fabric Community
    Solved: Re: API in dataflowgen2 - Microsoft Fabric Community

    This Document provides additional details about using web  API connector in Dataflow Gen2:
    How to create a REST connection - Microsoft Fabric | Microsoft Learn

    Hope this helps. Please reach out for further assistance

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly and a kudos would be appreciated.

    Best Regards,
    Vinay.