Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
SteveCnz
Advocate I
Advocate I

Accessing Microsoft Graph with Power BI (Calendar entries and emails etc)

There are a couple of posts out there that demonstrate accessing the Microsoft Graph data from the OData feed in PowerBI such as Pathy's blog Access Microsoft Graph using power bi.  All the posts on the subject demonstrate accessing users in the organisation which I have all successfully tested on my own Office 365 tenant logging in with my organisational account.  

 

Has anyone been able to access the Microsoft Graph from Power BI for their own calendar entries or email using the same approach  (e.g. https://graph.microsoft.com/v1.0/me/events?$select=subject,body,bodyPreview,organizer,attendees,star... When I try I get this message.  

 

image.png

If accessing O365 users works signing in with an organisational account, I find it strange that accessing calendar entries does not, particularly as they are my calendar entries and I am admin of my O365 organisation.  

 

There is a lot of great information available in the Microsoft graph.  I would be grateful for any guidance on accessing Microsoft Graph from PowerBI (not just accessing users).  

 

I have gone into the Office Graph and registered an app, got a keys etc,  but it isn't clear where these keys shuld go, and I have read that Power BI does support OAuth 2 authentiication.   Also, I want to use the Microsoft graph api because I want the recurring appointments expanded, which the native Exchange apis provided in Power BI do not do.  

 

I am hoping that there is a straightforward solution to accessing this information.  I look foward to any guidance you might have.

3 REPLIES 3
SteveCnz
Advocate I
Advocate I

Thank you, much appreciated and apologies for taking so long to respond.  

 

I have managed to generate an access token (hundreds of characters long).  I am having trouble with the syntax in your recommendation.    Here is my M code based on your recommendation (note access token edited for security purposes).

 

let

Source = OData.Feed("https://graph.microsoft.com/beta/me/events?$select=subject,body,bodyPreview,organizer,attendees,start,end,location", null, [Headers = [Authorization = "Bearer YTU4OC1lNTMyLTQ1YjEtODA5NS1iMmFhODM4NmExODgiLCJlX2V4cCI6MjYyODAwLCJmYW1pbHlfbmFtZSI6IkNvcGxleSIsImdpdmVuX25hbWUiOiJTdGV2ZW4iLCJpcGFkZHIiOiIyMDMuMTg0LjMxLjYxIiwibmFtZSI6IlN0ZXZlbiBDb3BsZXkiLCJvaWQiOiI2NzMxOWFiNy1mZjQxLTRlMGEtODQ1Yi0xOTFhYjFiMGEwNjQiLCJwbGF0ZiI6IjMiLCJwdWlkIjoiMTAwMzNGRkY4NEZGRUE4QyIsInNjcCI6IlVzZXIuUmVhZCIsInN1YiI6Ik1JMndYTURyV011bjRQRW5DaGx5Um1Ddzk4dWJaRHVwVERHR1lOS09zblkiLCJ0aWQiOiIxYjBhNzdiZC1hMDY4LTQ2ZjQtYjM4MS1mYTM5NGRlMDA1MWEiLCJ1bmlxdWVfbmFtZSI6InN0ZXZlLmNvcGxleUBmYWlyYnJpZGdlLmJpeiIsInVwbiI6InN0ZXZlLmNvcGxleUBmYWlyYnJpZGdlLmJpeiIsInV0aSI6Ilp2T2xNdnVrRWtPZkxLYXVxS3dGQUEiLCJ2ZXIiOiIxLjAifQ.fDOscsbVuIYB0Cg9yLZZB8Q4nR9Om_bjQmqZlf7JvwwclyADq80c5G7cZBkzHnUnJMJk-xayQ7jT4RvKc7yHQ5alOY1M0v5YF4z50WJ23YadAcGxiQ3_lzdzkApMPRd6_WIDJZJPXPXs5mtbmtkBK3PEvNsS9ZkJ_uSGM_KEnZ6d_HSbng2tjOV9t3h_R92H5NFQBWWJRn8KtDxwWClYH8DTZDe626plrEgCJQuRwedWzqI5j8KWhtwV5SCg6gUCapS38NkCHc_i4P3NOF8rk-BRYszXwNXxEa_JbLvZ1lVZZW9Kh9H-DY0WL9IS2k2HRsqD65LwZdwWw6_m_fILvg" ] ])

in

Source

I am struggling with the exact syntax.   I get this error in the advanced editor with this code "Expression.Error: The 'Authorization' header is only supported when connecting anonymously. These headers can be used with all authentication types: Accept, Accept-Charset, Accept-Encoding, Accept-Language, Cache-Control, Content-Type, If-Modified-Since, Prefer, Referer"

 

Could you just provide an example of M code with an actual URL to MS graph and an actual (but edited so it does not actually login ) access token that has actually worked for you?     That would be fantastic.  Much appreciated.  

Anonymous
Not applicable

@SteveCnz,

Replace <Your token> in the following code with your token, then paste the code to the Advanced Editor of a blank query, do you get any error messages?

 

 

let

Source = OData.Feed("URL", null, [Headers = [Authorization = "Bearer <Your token>" ] ])

in

Source


And you can follow the instructions in this article to get your access token.

Reference:
https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/user_list_events

 

Regards,

Lydia

Thank you, much appreciated and apologies for taking so long to respond.  

 

I have managed to generate an access token (hundreds of characters long).  I am having trouble with the syntax in your recommendation.    Here is my M code based on your recommendation (note access token edited for security purposes).

 

let

Source = OData.Feed("https://graph.microsoft.com/beta/me/events?$select=subject,body,bodyPreview,organizer,attendees,start,end,location", null, [Headers = [Authorization = "Bearer YTU4OC1lNTMyLTQ1YjEtODA5NS1iMmFhODM4NmExODgiLCJlX2V4cCI6MjYyODAwLCJmYW1pbHlfbmFtZSI6IkNvcGxleSIsImdpdmVuX25hbWUiOiJTdGV2ZW4iLCJpcGFkZHIiOiIyMDMuMTg0LjMxLjYxIiwibmFtZSI6IlN0ZXZlbiBDb3BsZXkiLCJvaWQiOiI2NzMxOWFiNy1mZjQxLTRlMGEtODQ1Yi0xOTFhYjFiMGEwNjQiLCJwbGF0ZiI6IjMiLCJwdWlkIjoiMTAwMzNGRkY4NEZGRUE4QyIsInNjcCI6IlVzZXIuUmVhZCIsInN1YiI6Ik1JMndYTURyV011bjRQRW5DaGx5Um1Ddzk4dWJaRHVwVERHR1lOS09zblkiLCJ0aWQiOiIxYjBhNzdiZC1hMDY4LTQ2ZjQtYjM4MS1mYTM5NGRlMDA1MWEiLCJ1bmlxdWVfbmFtZSI6InN0ZXZlLmNvcGxleUBmYWlyYnJpZGdlLmJpeiIsInVwbiI6InN0ZXZlLmNvcGxleUBmYWlyYnJpZGdlLmJpeiIsInV0aSI6Ilp2T2xNdnVrRWtPZkxLYXVxS3dGQUEiLCJ2ZXIiOiIxLjAifQ.fDOscsbVuIYB0Cg9yLZZB8Q4nR9Om_bjQmqZlf7JvwwclyADq80c5G7cZBkzHnUnJMJk-xayQ7jT4RvKc7yHQ5alOY1M0v5YF4z50WJ23YadAcGxiQ3_lzdzkApMPRd6_WIDJZJPXPXs5mtbmtkBK3PEvNsS9ZkJ_uSGM_KEnZ6d_HSbng2tjOV9t3h_R92H5NFQBWWJRn8KtDxwWClYH8DTZDe626plrEgCJQuRwedWzqI5j8KWhtwV5SCg6gUCapS38NkCHc_i4P3NOF8rk-BRYszXwNXxEa_JbLvZ1lVZZW9Kh9H-DY0WL9IS2k2HRsqD65LwZdwWw6_m_fILvg" ] ])

in

Source

I am struggling with the exact syntax.   I get this error in the advanced editor with this code "Expression.Error: The 'Authorization' header is only supported when connecting anonymously. These headers can be used with all authentication types: Accept, Accept-Charset, Accept-Encoding, Accept-Language, Cache-Control, Content-Type, If-Modified-Since, Prefer, Referer"

 

Could you just provide an example of M code with an actual URL to MS graph and an actual (but edited so it does not actually login ) access token that has actually worked for you?     That would be fantastic.  Much appreciated.  

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.