-
Notifications
You must be signed in to change notification settings - Fork 18
/
get-TableOfUsersFromMicrosoftGraphAPI.pq
75 lines (75 loc) · 3.4 KB
/
get-TableOfUsersFromMicrosoftGraphAPI.pq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
let
output =
(AzureADTenantID as text, AzureApplicationClientID as text, AzureApplicationClientSecret as text) as table =>
let
out =
let
token_uri =
"https://login.windows.net/"
& AzureADTenantID
& "/oauth2/token",
resource = "https://graph.microsoft.com",
tokenResponse =
Json.Document(
Web.Contents(
token_uri,
[
Content =
Text.ToBinary(
Uri.BuildQueryString(
[
client_id = AzureApplicationClientID,
resource = resource,
grant_type = "client_credentials",
client_secret = AzureApplicationClientSecret
]
)
),
Headers = [
Accept = "application/json"
],
ManualStatusHandling = {
400
}
]
)
),
access_token = tokenResponse[access_token],
src =
OData.Feed(
"https://graph.microsoft.com/beta/users",
[Authorization = "Bearer " & access_token],
[
ExcludedFromCacheKey = {
"Authorization"
},
ODataVersion = 4,
Implementation = "2.0"
]
)
in
src
in
out,
documentation = [
Documentation.Name = " get-TableOfUsersFromMicrosoftGraphAPI.pq ",
Documentation.Description = " Getting table with data from Microsoft Graph API about Users ",
Documentation.Source = "https://www.jaknapowerbi.cz",
Documentation.Version = " 1.0 ",
Documentation.Author = " Štěpán Rešl ",
Documentation.Examples = {
[
Description = " All Data Credentials have to be ""Anonymous"" ",
Code = " Input: AzureADTenantID = 00000000-aaaa-bbb0-ccc2-121212121212, AzureApplicationClientID = 00000000-aaaa-bbb0-ccc2-121212121212, AzureApplicationClientSecret = PPPSssssssst1________.__. ",
Result = "#table"
]
}
]
in
Value.ReplaceType(
output,
Value.ReplaceMetadata(
Value.Type(output),
documentation
)
)