The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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.