Home

How to authenticate a script without user interaction?

%3CLINGO-SUB%20id%3D%22lingo-sub-754435%22%20slang%3D%22en-US%22%3EHow%20to%20authenticate%20a%20script%20without%20user%20interaction%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-754435%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20want%20to%20get%20started%20with%20the%20Graph%20API.%20I%20am%20interested%20in%20automation%2C%20so%20all%20the%20'Getting%20Started'%20documentation%20is%20not%20helpful%2C%20because%20it%20relies%20on%20user%20interaction%20during%20the%20authentication.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20registered%20an%20app%20and%20granted%20it%20the%20%3CEM%3EUser.Read.All%3C%2FEM%3EAPI%20permission%20(type%3Aapplication)%20and%20I%20created%20a%20client%20secret%20%2F%20application%20password.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENow%20I'm%20stuck.%20Does%20anybody%20have%20a%20sample%20Python%20script%20that%20authenticates%3F%20And%20maybe%20even%20gets%20a%20list%20of%20users%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-766868%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20authenticate%20a%20script%20without%20user%20interaction%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-766868%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F65328%22%20target%3D%22_blank%22%3E%40Daniel%20Niccoli%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHave%20you%20checked%20the%20below%20post%20%3F%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fauth-v2-service%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fauth-v2-service%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-768676%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20authenticate%20a%20script%20without%20user%20interaction%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-768676%22%20slang%3D%22en-US%22%3EHi%20Daniel%2C%3CBR%20%2F%3E%3CBR%20%2F%3EI%20would%20recommend%20reading%20the%20documentation%20Kevin%20suggested.%20%3CBR%20%2F%3E%3CBR%20%2F%3EI%20wrote%20a%20small%20python%20script%20that%20may%20help%20you%20understand%20authentication%2C%20it%20was%20written%20with%20the%20Microsoft%20Graph%20Security%20API%20endpoint%20in%20mind.%20But%20the%20authentication%20should%20be%20the%20same%20and%20you%20can%20use%20the%20%22make_request%22%20method%20with%20the%20url%20%22%3CA%20href%3D%22https%3A%2F%2Fgraph.microsoft.com%2Fv1.0%2Fusers%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgraph.microsoft.com%2Fv1.0%2Fusers%3C%2FA%3E%22%20to%20get%20all%20your%20users.%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoftgraph%2Fsecurity-api-solutions%2Fblob%2Fmaster%2FQuickStarts%2FPython%2FPython_QuickStart.py%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fmicrosoftgraph%2Fsecurity-api-solutions%2Fblob%2Fmaster%2FQuickStarts%2FPython%2FPython_QuickStart.py%3C%2FA%3E%20%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E
Frequent Contributor

Hi,

 

I want to get started with the Graph API. I am interested in automation, so all the 'Getting Started' documentation is not helpful, because it relies on user interaction during the authentication.

 

I registered an app and granted it the User.Read.All API permission (type:application) and I created a client secret / application password.

 

Now I'm stuck. Does anybody have a sample Python script that authenticates? And maybe even gets a list of users?

 

2 Replies
Hi Daniel,

I would recommend reading the documentation Kevin suggested.

I wrote a small python script that may help you understand authentication, it was written with the Microsoft Graph Security API endpoint in mind. But the authentication should be the same and you can use the "make_request" method with the url "https://graph.microsoft.com/v1.0/users" to get all your users.

https://github.com/microsoftgraph/security-api-solutions/blob/master/QuickStarts/Python/Python_Quick...
Related Conversations
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
cntvertex in Discussions on
13 Replies
Tabs and Dark Mode
cjc2112 in Discussions on
22 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
28 Replies
Edge insider Dev bypasses IE mode website list
HotCakeX in Enterprise on
4 Replies