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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
pdesmarais
Frequent Visitor

GraphAPi Anonymous with API Token can't be refreshed while published.

 

I use GrapAPi with ClientCredentials, where a Token is obtain and used to gather details.

When published on the WEB this connections requires credentials, but it shouldnt as a Token is passed.

EVen if i set anonymous it fails. Any alternatives i could work out?

 

2018-03-05 06_49_59-Power BI.png

 

 

let
    client_id = ClientID,
    client_secret=Client_secret,
 
    //Authentication
    
   //URI's
    redirect_uri = "https://portal.office.com",
    token_uri = "https://login.windows.net/.onmicrosoft.com/oauth2/token", 
    authorize_uri = "https://login.windows.net/.onmicrosoft.com/oauth2/authorize",
    resource="https://graph.microsoft.com/",
   
 
   tokenResponse = Json.Document(Web.Contents(token_uri,          
                                [
                                    Content=
                                    Text.ToBinary(Uri.BuildQueryString(
                                    [
                                        client_id = client_id
                                        ,client_secret=client_secret
                                        ,resource=resource
                                        ,grant_type = "client_credentials"
                                        ,redirect_uri = redirect_uri
                                    ]))
                                    ,Headers=
                                        [Accept="application/json"]
                                        , ManualStatusHandling={400}
                                ])),
                                access_token = tokenResponse[access_token],
    token = tokenResponse[access_token],
getdatasets_uri ="https://graph.microsoft.com/stagingBeta/reports/getTenantSecureScores(period=1)/content",
GetGroups = Json.Document(Web.Contents(getdatasets_uri,[Headers=[Authorization="Bearer " & token]])),
    #"Converted to Table1" = Table.FromList(GetGroups, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table1", "Column1", {"tenantId", "createdDate", "licensedUserCount", "activeUserCount", "secureScore", "maxSecureScore", "accountScore", "dataScore", "deviceScore", "enabledServices", "controlScores", "averageSecureScore", "averageMaxSecureScore", "averageAccountScore", "averageDataScore", "averageDeviceScore", "averageScores"}, {"tenantId", "createdDate", "licensedUserCount", "activeUserCount", "secureScore", "maxSecureScore", "accountScore", "dataScore", "deviceScore", "enabledServices", "controlScores", "averageSecureScore", "averageMaxSecureScore", "averageAccountScore", "averageDataScore", "averageDeviceScore", "averageScores"}),
    #"Expanded createdDate" = Table.ExpandRecordColumn(#"Expanded Column1", "createdDate", {"Year", "Month", "Day"}, {"createdDate.Year", "createdDate.Month", "createdDate.Day"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded createdDate",{{"secureScore", Int64.Type}, {"maxSecureScore", Int64.Type}})
in
    #"Changed Type"

 

1 REPLY 1
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @pdesmarais,

 

It seems to be that refresh for data source which authenticated with API call within the query is not supported currently.

 

Here is a similar idea shared on Power BI Ideas forum. You can vote it up and add your comments there to improve Power BI on this feature. Smiley Happy

 

Regards

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.