cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
sakalasiva Frequent Visitor
Frequent Visitor

How to authenticate Web data source: REST API with AAD token access

 I am trying to access data from REST WEB API protected by AAD token. How can I dynamically pass AAD token to be used in data source header to get authorized and retrive data from API.

4 REPLIES 4
Seward12533 New Contributor
New Contributor

Re: How to authenticate Web data source: REST API with AAD token access

I struggled with somethig similar for a JSON query, after mucking around with it for a while I got this work.  Not sure if it the same for REST API but may help you.

 

snip_20180812000125.png

 

let
    Source = Web.Contents("https://www.wrike.com/api/v3/customfields",
                [Headers=[#"Authorization"="bearer m5W.......,FIUK"]
                ]),
    convertToJson = Json.Document(Source),
    data = convertToJson[data],
    #"Converted to Table" = Table.FromList(data, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"id", "title", "type"}, {"id", "title", "type"})
in
    #"Expanded Column1"

sakalasiva Frequent Visitor
Frequent Visitor

Re: How to authenticate Web data source: REST API with AAD token access

Thanks for your reply. I am creating report which will be used by different customers with different AAD token values. Is there a way to pass AAD token value programatically to authorization header instead of hard coding it.  

Seward12533 New Contributor
New Contributor

Re: How to authenticate Web data source: REST API with AAD token access

You can use parameters there are many related solutions in the forum for that try searching parameters PowerQuery and if you can’t find what your looking for post a new question.
sunny12 New Member
New Member

Re: How to authenticate Web data source: REST API with AAD token access

I am also facing the same issue. 

Below is my query to configure the data source

 

let
Source = Json.Document(Web.Contents("https://www.myapirul.com", [Headers=[Authorization=#"AuthenticationToken"]])),
chartMaintenances = Source[chartMaintenances],
#"Converted to Table" = Table.FromList(chartMaintenances, Splitter.SplitByNothing(), null, null, ExtraValues.Ignore),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"WorkOrderNo", "MaintenanceID", "MaintenanceType", "MaintenancePart", "Description", "RaisedBy", "DaysOpen"}, {"Column1.WorkOrderNo", "Column1.MaintenanceID", "Column1.MaintenanceType", "Column1.MaintenancePart", "Column1.Description", "Column1.RaisedBy", "Column1.DaysOpen"})
in
#"Expanded Column1"

 

where AuthenticationToken is the parameter I have created.  When I execute this in PowerBi desktop application, it runs successfully and retrieves the value from the created parameter AuthenticationToken. Now I have doubts about how to pass AuthenticationToken parameter value from embedded power bi application using .net mvc

Helpful resources

Announcements
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors (Last 30 Days)