We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
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 have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 10 | |
| 8 | |
| 7 | |
| 7 | |
| 5 |