Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Sign up nowGet Fabric certified for FREE! Don't miss your chance! Learn more
Access token got expired after 60 minutes, need to refresh it to fetch the information from GRAPH API.
Below is the power query code using :
let
token_uri = "https://login.windows.net/" & #"Azure AD Tenant ID" & "/oauth2/token",
resource = "https://graph.microsoft.com",
tokenResponse = Json.Document(Web.Contents(token_uri,
[
Content = Text.ToBinary(Uri.BuildQueryString(
[
client_id = #"Azure Application Client ID",
resource = resource,
grant_type = "client_credentials",
client_secret = #"Azure Application Client Secret"
]
)),
Headers = [Accept = "application/json"], ManualStatusHandling = {400}
])),
access_token = tokenResponse[access_token],
Source = OData.Feed("https://graph.microsoft.com/v1.0/devices?$select=id, accountEnabled, approximateLastSignInDateTime, deviceId, displayName, isCompliant, isManaged, mdmAppId, onPremisesLastSyncDateTime, onPremisesSyncEnabled, operatingSystem, operatingSystemVersion, trustType, registeredOwners, registeredUsers", [ Authorization = "Bearer " & access_token ], [ ExcludedFromCacheKey = {"Authorization"}, ODataVersion = 4, Implementation = "2.0" ]),
#"Expanded registeredOwners" = Table.ExpandTableColumn(Source, "registeredOwners", {"id"}, {"id.1"}),
#"Remove columns" = Table.RemoveColumns(#"Expanded registeredOwners", Table.ColumnsOfType(#"Expanded registeredOwners", {type table, type record, type list, type nullable binary, type binary, type function}))
in
#"Remove columns"
Hi, @Anonymous
We can still customize the lifetime of the access token by configuring the token lifetime policy.
$policy = New-AzureADPolicy -Definition @('{"TokenLifetimePolicy":{"Version":1,"AccessTokenLifetime":"00:15:00"}}') -DisplayName "WebPolicyScenario" -IsOrganizationDefault $false -Type "TokenLifetimePolicy"
Hope this helps.
Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 13 | |
| 11 | |
| 11 | |
| 8 | |
| 6 |