Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Kaveesha_Silva
Frequent Visitor

Store client credentials securely

I am retrieving an access token by calling an API and then use this access token to obtain employee data. I'm using a blank query with the following code.

 

 

    body="grant_type=client_credentials&client_id="&<client_id>&"client_secret="&<client_secret>,
    Source  = Json.Document(Web.Contents(baseUrl,
        [ 
          RelativePath = "oauth/issueToken",
          Headers = [#"Content-Type"="application/x-www-form-urlencoded"],
          Content=Text.ToBinary(body)  
        ]
    )),

    token = Source[access_token],

    data= Json.Document(Web.Contents(baseUrl,
      [ 
        RelativePath = "api/employees",
        Headers = [#"Authorization"="Bearer "&token]
      ]
    )),

 

 

 

I'm getting access token calling our own API (not using AAD). What is the best way to store these client credentials (client_id and client_secret) instead of hardcoding in the code?

2 REPLIES 2
ams1
Super User
Super User

Besides the great option @lbendlin mentioned, with an additional API endpoint you could also use the builtin credentials manager https://community.powerbi.com/t5/Power-Query/How-to-securely-store-and-use-token-and-secret-for-API-...

 

lbendlin
Super User
Super User

store them in a text file in a sharepoint document library that only you have access to. Then retrieve that file as part of the Power Query transforms etc.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.