Writing a simple microsoft graph client without us

2019-07-10 04:28发布

问题:

I'm looking to write a script to update a Distribution List in Office365. I'm in the process of learning the MS Graph API and have gotten the python REST sample to work. It appears that all the sample Graph API code, regardless of language or platform, has an assumption that I'm coding from a web user interface in one way or another.

Is it possible to write a simple client that runs from a Linux box and allows me to specify my Office 365 id in my code, without having to select it from a browser? My goal is to have this run as a cron job which updates the Distribution List nightly. Python is not a requirement, it's just where I chose to start in learning Graph.

回答1:

The Graph API is not restricted to web apps and can be used in native/desktop apps as well. Essentially you have to start by registering your app to get your app ID, then use whatever REST APIs you want to implement the Auth Code Grant flow to get access. When you first issue a request the user will be prompted to sign in with their Office 365 account to grant access to your app, and away you go.

https://graph.microsoft.io/en-us/docs/get-started/rest