Forum Discussion

LukasB's avatar
LukasB
New Member
4 years ago
Solved

Connect to GraphAPI with AAD registered App

Hi, 

 

I want to connect to Graph API and authenticate with a AAD App registration.

 

What works so far: 

I was able to generate a Bearer Token with this Query:

 

= let
BodyRecord = [grant_type = "client_credentials", resource = "CLIENTID", client_id = "CLIENTID", client_secret = "SECRET"],
Body = Uri.BuildQueryString(BodyRecord),
API = Web.Contents("https://login.microsoft.com/TENANT-URL/oauth2/token?api-version=1.0", [Content=Text.ToBinary(Body)]),
ChangeResponseToRecord = Json.Document(Text.FromBinary(API)),
GetAccessToken = ChangeResponseToRecord[access_token]
in
GetAccessToken

 

After this I added a new step and tried to use the Token to get some data from Graph, but there are some problems with the authentication. I used this Query:

 

= let data = Json.Document(Web.Contents("https://graph.microsoft.com/v1.0/users",
[
Headers = [
#"Authorization"="Bearer "&TOKEN, #"Content-Type"="application/json",
Accept="application/json"]

]
)
) in data

 

But then it asks me how I want to authenticate:

 

When choosing "Anonymous" it does not work (I think because Graph blocks anonymous connections):

 

"Web API" also does not work, no matter what I type into the Key field (don´t even know what to type here):

 

Any Ideas how I can get the Authentication running?

 

Thanks a lot!

 

1 Reply