Authorization and Microsoft Graph Security API

%3CLINGO-SUB%20id%3D%22lingo-sub-184376%22%20slang%3D%22en-US%22%3EAuthorization%20and%20Microsoft%20Graph%20Security%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-184376%22%20slang%3D%22en-US%22%3E%3CH1%20id%3D%22toc-hId-1819975942%22%20id%3D%22toc-hId-354722524%22%20id%3D%22toc-hId-354722524%22%20id%3D%22toc-hId-354722524%22%20id%3D%22toc-hId-1819975942%22%3E%3CFONT%20color%3D%22%230000ff%22%3EUnderstanding%20authorization%20when%20calling%20the%20Microsoft%20Graph%20Security%20API%3C%2FFONT%3E%3C%2FH1%3E%0A%3CP%3E%3CSTRONG%3EHigh-level%20summary%3C%2FSTRONG%3E%3A%20Security%20data%20accessible%20via%20the%20Microsoft%20Graph%20Security%20API%20is%20very%20sensitive%20and%20is%20protected%20using%20both%20permissions%20(aka%20scopes)%20and%20Azure%20AD%20(AAD)%20roles.%3C%2FP%3E%0A%3CP%3EMicrosoft%20Graph%20Security%20API%20supports%20two%20types%20of%20application%20authorization%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EApplication-level%20authorization%3C%2FSTRONG%3E%2C%20where%20there%20is%20no%20signed-in%20user%20(e.g.%20a%20SIEM%20scenario).%3CBR%20%2F%3E%20Here%20the%20permissions%2Fscopes%20granted%20to%20the%20application%20determine%20authorization.%3CBR%20%2F%3ENote%3A%20this%20option%20can%20also%20support%20cases%20where%20%3CEM%3ERole-Based%20Access%20Control%3C%2FEM%3E%20(aka%20RBAC)%20is%20managed%20by%20the%20application.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EUser%20delegated%20authorization%3C%2FSTRONG%3E%2C%20where%20a%20user%20who%20is%20a%20member%20of%20the%20AAD%20tenant%20is%20signed%20in.%3CBR%20%2F%3E%20Here%20the%20user%20must%20be%20a%20member%20of%20an%20AAD%20Limited%20Admin%20role%20-%20either%20%3CEM%3ESecurity%20Reader%3C%2FEM%3E%20or%20%3CEM%3ESecurty%20Administrator%3C%2FEM%3E%2C%20%3CU%3Ein%20addition%20to%3C%2FU%3E%20the%20application%20having%20been%20granted%20the%20required%20permissions%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EWe%20distinguish%20between%20two%20types%20of%20client%20applications%3A%20the%20Microsoft%20Graph%20Explorer%2C%20and%20custom%20client%20applications.%3C%2FP%3E%0A%3CP%3EIf%20calling%20from%20Graph%20Explorer%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EThe%20AAD%20tenant%20admin%20must%20explicitly%20grant%20consent%20for%20the%20requested%20permissions%20to%20the%20Graph%20Explorer%20application%3C%2FLI%3E%0A%3CLI%3EThe%20user%20must%20be%20a%20member%20of%20the%20Security%20Reader%20Limited%20Admin%20role%20in%20AAD%20(either%20%3CEM%3ESecurity%20Reader%3C%2FEM%3E%20or%20%3CEM%3ESecurity%20Administrator%3C%2FEM%3E)%3C%2FLI%3E%0A%3CLI%3ENote%3A%20Graph%20Explorer%20does%20not%20support%20application-level%20authorization%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EIf%20calling%20from%20a%20custom%2Fyour%20own%20application%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EThe%20AAD%20tenant%20admin%20must%20explicitly%20grant%20consent%20to%20your%20application.%20This%20is%20required%20both%20for%20application-level%20authorization%20as%20well%20as%20for%20user%20delegated%20authorization%3C%2FLI%3E%0A%3CLI%3EIf%20using%20user%20delegated%20authorization%2C%20the%20user%20must%20be%20a%20member%20of%20the%20%3CEM%3ESecurity%20Reader%3C%2FEM%3E%20or%20%3CEM%3ESecurity%20Administrator%3C%2FEM%3E%20Limited%20Admin%20role%20in%20AAD%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EThe%20following%20section%20contains%20a%20detailed%20technical%20explanation%20of%20using%20the%20Authorization%20mechanisms.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId--732181019%22%20id%3D%22toc-hId--1452731939%22%20id%3D%22toc-hId--1452731939%22%20id%3D%22toc-hId--1452731939%22%20id%3D%22toc-hId--732181019%22%3E%3CFONT%20color%3D%22%230000ff%22%3EManaging%20authorization%20in%20Microsoft%20Graph%20Security%20API%20client%20applications%3C%2FFONT%3E%3C%2FH1%3E%0A%3CP%3ESecurity%20data%20provided%20via%20the%20Microsoft%20Graph%20Security%20API%20is%20sensitive%20and%20must%20be%20protected%20by%20appropriate%20authentication%20and%20authorization%20mechanisms.%20To%20register%20and%20create%20a%20client%20application%20that%20can%20access%20the%20Microsoft%20Graph%20Security%20API%2C%20the%20following%20steps%20must%20be%20performed%3A%3C%2FP%3E%0A%3CTABLE%20width%3D%22630%22%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22210%22%3E%3CP%3E%3CSTRONG%3EWho%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22420%22%3E%3CP%3E%3CSTRONG%3EAction%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22210%22%3E%3CP%3EApplication%20developer%20or%20owner%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22420%22%3E%3CP%3ERegister%20application%20as%20an%20enterprise%20application%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22210%22%3E%3CP%3ETenant%20Admin%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22420%22%3E%3CP%3EGrant%20permissions%20to%20the%20application%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22210%22%3E%3CP%3ETenant%20Admin%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22420%22%3E%3CP%3EAssign%20Limited%20Administrator%20roles%20to%20users%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22210%22%3E%3CP%3EApplication%20developer%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22420%22%3E%3CP%3ESign-in%20as%20the%20user%20and%20use%20application%20to%20access%20Graph%20Security%20API%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ETo%20clarify%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EApplication%20registration%3C%2FSTRONG%3E%20only%20defines%20which%20permissions%20the%20application%20needs%20in%20order%20to%20run.%20%3CBR%20%2F%3E%20It%20does%20NOT%20grant%20these%20permissions%20to%20the%20application.%3C%2FLI%3E%0A%3CLI%3EThe%20Azure%20AD%20tenant%20administrator%20MUST%20explicitly%20grant%20the%20permissions%20to%20the%20application.%20%3CBR%20%2F%3E%20This%20MUST%20be%20done%20per%20tenant%20and%20%3CU%3Eperformed%20every%20time%3C%2FU%3E%20the%20application%20permissions%20are%20changed%20in%20the%20application%20registration%20portal.%3C%2FLI%3E%0A%3CLI%3ELet%E2%80%99s%20assume%20we%20have%3A%20an%20application%3A%20%3CFONT%20color%3D%22%230000ff%22%3E%3CSTRONG%3EApp%3C%2FSTRONG%3E%3C%2FFONT%3E%2C%20two%20AAD%20tenants%3A%20%3CFONT%20color%3D%22%23008000%22%3E%3CSTRONG%3ET1%3C%2FSTRONG%3E%20%3C%2FFONT%3Eand%20%3CFONT%20color%3D%22%23008000%22%3E%3CSTRONG%3ET2%3C%2FSTRONG%3E%3C%2FFONT%3E%2C%20and%20two%20scopes%2C%20or%20permissions%3A%20%3CFONT%20color%3D%22%23800000%22%3E%3CSTRONG%3EP1%3C%2FSTRONG%3E%20%3C%2FFONT%3Eand%20%3CFONT%20color%3D%22%23800000%22%3E%3CSTRONG%3EP2%3C%2FSTRONG%3E%3C%2FFONT%3E.%3CUL%3E%0A%3CLI%3EApplication%20%3CFONT%20color%3D%22%230000ff%22%3E%3CSTRONG%3EApp%3C%2FSTRONG%3E%20%3C%2FFONT%3Eregistered%20to%20require%20permission%20%3CFONT%20color%3D%22%23800000%22%3E%3CSTRONG%3EP1%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3EWhen%20users%20in%20tenant%20%3CFONT%20color%3D%22%23008000%22%3E%3CSTRONG%3ET1%3C%2FSTRONG%3E%20%3C%2FFONT%3Eget%20an%20AAD%20token%20for%20this%20application%2C%20the%20token%20does%20not%20contain%20any%20permissions%20(see%20next%20bullet)%3C%2FLI%3E%0A%3CLI%3EThe%20AAD%20Admin%20of%20tenant%20%3CFONT%20color%3D%22%23008000%22%3E%3CSTRONG%3ET1%3C%2FSTRONG%3E%20%3C%2FFONT%3Eexplicitly%20grants%20permissions%20to%20the%20application%20%3CFONT%20color%3D%22%230000ff%22%3E%3CSTRONG%3EApp%3C%2FSTRONG%3E%3C%2FFONT%3E.%20From%20this%20moment%20on%2C%20when%20users%20in%20tenant%20%3CFONT%20color%3D%22%23008000%22%3E%3CSTRONG%3ET1%3C%2FSTRONG%3E%3C%2FFONT%3E%20get%20an%20AAD%20token%20for%20%3CFONT%20color%3D%22%230000ff%22%3E%3CSTRONG%3EApp%3C%2FSTRONG%3E%3C%2FFONT%3E%2C%20it%20will%20contain%20permission%20%3CFONT%20color%3D%22%23800000%22%3E%3CSTRONG%3EP1%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3EWhen%20users%20in%20tenant%20%3CFONT%20color%3D%22%23008000%22%3E%3CSTRONG%3ET2%3C%2FSTRONG%3E%20%3C%2FFONT%3Eget%20an%20AAD%20token%20for%20application%20%3CFONT%20color%3D%22%230000ff%22%3E%3CSTRONG%3EApp%3C%2FSTRONG%3E%3C%2FFONT%3E%2C%20the%20token%20does%20not%20contain%20any%20permissions%20-%20because%20the%20admin%20of%20tenant%20%3CFONT%20color%3D%22%23008000%22%3E%3CSTRONG%3ET2%3C%2FSTRONG%3E%20%3C%2FFONT%3Edid%20not%20yet%20grant%20permissions%20to%20%3CFONT%20color%3D%22%230000ff%22%3E%3CSTRONG%3EApp%3C%2FSTRONG%3E%3C%2FFONT%3E.%20%3CBR%20%2F%3E%20The%20procedure%20of%20granting%20permission%20must%20be%20performed%20%3CU%3Eper%20tenant%3C%2FU%3E%20and%20%3CU%3Eper%20application%3C%2FU%3E%3C%2FLI%3E%0A%3CLI%3EThe%20application%20App%20has%20its%20registration%20changed%20to%20now%20require%20permissions%20%3CSTRONG%3E%3CFONT%20color%3D%22%23800000%22%3EP1%3C%2FFONT%3E%20%3C%2FSTRONG%3Eand%3CFONT%20color%3D%22%23800000%22%3E%3CSTRONG%3E%20P2%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FLI%3E%0A%3CLI%3EWhen%20users%20in%20tenant%20%3CFONT%20color%3D%22%23008000%22%3E%3CSTRONG%3ET1%3C%2FSTRONG%3E%20%3C%2FFONT%3Eget%20an%20AAD%20token%20for%20%3CFONT%20color%3D%22%230000ff%22%3E%3CSTRONG%3EApp%3C%2FSTRONG%3E%3C%2FFONT%3E%2C%20it%20only%20contains%20permission%20%3CFONT%20color%3D%22%23800000%22%3E%3CSTRONG%3EP1%3C%2FSTRONG%3E.%3C%2FFONT%3E%20Permissions%20granted%20to%20an%20application%20are%20recorded%20as%20snapshots%20of%20what%20was%20granted%20-%20%3CBR%20%2F%3E%20they%20%3CSTRONG%3Edo%20not%20change%20automatically%3C%2FSTRONG%3E%20after%20the%20application%20registration%20(permission)%20changes%3C%2FLI%3E%0A%3CLI%3EThe%20admin%20of%20tenant%20%3CFONT%20color%3D%22%23008000%22%3E%3CSTRONG%3ET2%3C%2FSTRONG%3E%20%3C%2FFONT%3Egrants%20permissions%20%3CSTRONG%3E%3CFONT%20color%3D%22%23800000%22%3EP1%3C%2FFONT%3E%20%3C%2FSTRONG%3Eand%3CFONT%20color%3D%22%23800000%22%3E%3CSTRONG%3E%20P2%3C%2FSTRONG%3E%20%3C%2FFONT%3Eto%20the%20application%20%3CFONT%20color%3D%22%230000ff%22%3E%3CSTRONG%3EApp%3C%2FSTRONG%3E%3C%2FFONT%3E.%20%3CBR%20%2F%3E%20From%20this%20moment%20on%2C%20when%20users%20in%20tenant%20%3CFONT%20color%3D%22%23008000%22%3E%3CSTRONG%3ET2%3C%2FSTRONG%3E%20%3C%2FFONT%3Eget%20AAD%20token%20for%20%3CFONT%20color%3D%22%230000ff%22%3E%3CSTRONG%3EApp%3C%2FSTRONG%3E%3C%2FFONT%3E%2C%20the%20token%20will%20contain%20permissions%20%3CSTRONG%3E%3CFONT%20color%3D%22%23800000%22%3EP1%3C%2FFONT%3E%20%3C%2FSTRONG%3Eand%3CFONT%20color%3D%22%23800000%22%3E%3CSTRONG%3E%20P2%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3ENote%3A%20for%20the%20same%20application%20(%3CFONT%20color%3D%22%230000ff%22%3E%3CSTRONG%3EApp%3C%2FSTRONG%3E%3C%2FFONT%3E)%2C%20the%20AAD%20token%20for%20the%20application%20in%20tenant%20%3CFONT%20color%3D%22%23008000%22%3E%3CSTRONG%3ET1%3C%2FSTRONG%3E%20%3C%2FFONT%3Eand%20that%20for%20the%20application%20in%20tenant%20%3CSTRONG%3E%3CFONT%20color%3D%22%23008000%22%3ET2%3C%2FFONT%3E%20%3C%2FSTRONG%3Econtain%20different%20permissions%2C%20since%20the%20tenant%20admins%20each%20granted%20different%20permissions%20to%20the%20application%20(%3CFONT%20color%3D%22%230000ff%22%3E%3CSTRONG%3EApp%3C%2FSTRONG%3E%3C%2FFONT%3E)%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ETo%20make%20%3CFONT%20color%3D%22%230000ff%22%3E%3CSTRONG%3EApp%3C%2FSTRONG%3E%20%3C%2FFONT%3Ework%20again%20in%20tenant%20%3CFONT%20color%3D%22%23008000%22%3E%3CSTRONG%3ET1%3C%2FSTRONG%3E%3C%2FFONT%3E%2C%20the%20admin%20of%20tenant%20%3CFONT%20color%3D%22%23008000%22%3E%3CSTRONG%3ET1%3C%2FSTRONG%3E%20%3C%2FFONT%3Emust%20explicitly%20grant%20permissions%20%3CSTRONG%3E%3CFONT%20color%3D%22%23800000%22%3EP1%3C%2FFONT%3E%20%3C%2FSTRONG%3Eand%3CFONT%20color%3D%22%23800000%22%3E%3CSTRONG%3E%20P2%3C%2FSTRONG%3E%20%3C%2FFONT%3Eto%20the%20application%20(%3CFONT%20color%3D%22%230000ff%22%3E%3CSTRONG%3EApp%3C%2FSTRONG%3E%3C%2FFONT%3E)%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH2%20id%3D%22toc-hId-814115811%22%20id%3D%22toc-hId--762170465%22%20id%3D%22toc-hId--762170465%22%20id%3D%22toc-hId--762170465%22%20id%3D%22toc-hId-814115811%22%3E%3CFONT%20color%3D%22%230000ff%22%3ERegister%26nbsp%3Ban%20Application%20in%20v2.0%20endpoint%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fdevelop%2Factive-directory-v2-app-registration%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EReference%20link%3C%2FA%3E%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1934554655%22%20id%3D%22toc-hId--71608991%22%20id%3D%22toc-hId--71608991%22%20id%3D%22toc-hId--71608991%22%20id%3D%22toc-hId--1934554655%22%3E%3CFONT%20color%3D%22%230000ff%22%3EWhat%20you%20need%3C%2FFONT%3E%3A%3C%2FH3%3E%0A%3CP%3E%3CSTRONG%3EApplication%20Name%3C%2FSTRONG%3E%3A%20a%20string%20used%20for%20the%20application%20name%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ERedirect%20URL%3C%2FSTRONG%3E%3A%20where%20the%20authentication%20response%20from%20AAD%20is%20sent%20to.%20%3CBR%20%2F%3E%20To%20begin%20with%2C%20you%20can%20use%20the%20test%20client%20web%20app%20homepage.%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ERequired%20Permissions%3C%2FSTRONG%3E%3A%20the%20permissions%20that%20your%20application%20requires%20to%20be%20able%20to%20call%20Microsoft%20Graph%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--191744320%22%20id%3D%22toc-hId--1879063454%22%20id%3D%22toc-hId--1879063454%22%20id%3D%22toc-hId--1879063454%22%20id%3D%22toc-hId--191744320%22%3E%3CFONT%20color%3D%22%230000ff%22%3EWhat%20you%20need%20to%20do%3C%2FFONT%3E%3A%3C%2FH3%3E%0A%3COL%3E%0A%3CLI%3EGo%20to%20%3CA%20href%3D%22https%3A%2F%2Fapps.dev.microsoft.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fapps.dev.microsoft.com%2F%3C%2FA%3E%20and%20sign%20in.%20%3CBR%20%2F%3E%20Note%3A%20there%20is%20no%20need%20to%20be%20a%20tenant%20admin.%20You%20will%20be%20redirected%20to%20%E2%80%9CMy%20applications%E2%80%9D%20list%3C%2FLI%3E%0A%3CLI%3EClick%20the%20%E2%80%9C%3CSTRONG%3EAdd%20an%20app%3C%2FSTRONG%3E%E2%80%9D%20button%2C%20and%20enter%20an%20Application%20Name%20to%20create%20a%20new%20application%3C%2FLI%3E%0A%3CLI%3EIt%20will%20navigate%20to%20the%20registration%20page%20for%20the%20new%20application.%20%3CBR%20%2F%3E%20Click%20%E2%80%9C%3CSTRONG%3EAdd%20Platform%3C%2FSTRONG%3E%E2%80%9D%2C%20choose%20%E2%80%9C%3CSTRONG%3EWeb%3C%2FSTRONG%3E%E2%80%9D.%20In%20the%20Redirect%20URL%2C%20enter%20the%20Redirect%20URL.%3C%2FLI%3E%0A%3CLI%3EGo%20to%20section%20%E2%80%9C%3CSTRONG%3EMicrosoft%20Graph%20Permissions%3C%2FSTRONG%3E%E2%80%9D%20and%20under%20%E2%80%9C%3CSTRONG%3EDelegated%20Permissions%3C%2FSTRONG%3E%E2%80%9D%2C%20click%20the%20%E2%80%9C%3CSTRONG%3EAdd%3C%2FSTRONG%3E%E2%80%9D%20button.%20A%20popup%20dialog%20appears%3B%20choose%20required%20permissions%20(aka%20scopes).%20%3CBR%20%2F%3E%20See%20this%20%3CA%20href%3D%22https%3A%2F%2Fdeveloper.microsoft.com%2Fen-us%2Fgraph%2Fdocs%2Fconcepts%2Fpermissions_reference%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Edocument%3C%2FA%3E%20for%20detailed%20scopes.%20The%20Microsoft%20Graph%20Security%20API%20requires%20%E2%80%9CSecurityEvents.Read.All%E2%80%9D%20scope%20for%20GET%20queries%2C%20and%20%E2%80%9CSecurityEvents.ReadWrite.All%E2%80%9D%20scope%20for%20PATCH%2FPOST%20queries.%3C%2FLI%3E%0A%3CLI%3EScroll%20down%20to%20the%20bottom%20of%20the%20page%20and%20click%20on%20the%20%E2%80%9C%3CSTRONG%3ESave%3C%2FSTRONG%3E%E2%80%9D%20button%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CH3%20id%3D%22toc-hId-1551066015%22%20id%3D%22toc-hId-608449379%22%20id%3D%22toc-hId-608449379%22%20id%3D%22toc-hId-608449379%22%20id%3D%22toc-hId-1551066015%22%3E%3CFONT%20color%3D%22%230000ff%22%3EWhat%20to%20save%20for%20future%20steps%3C%2FFONT%3E%3A%3C%2FH3%3E%0A%3CUL%3E%0A%3CLI%3EApplication%20Id%3C%2FLI%3E%0A%3CLI%3ERedirect%20URL%3C%2FLI%3E%0A%3CLI%3EList%20of%20required%20permissions%26nbsp%3B%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH2%20id%3D%22toc-hId--804577441%22%20id%3D%22toc-hId-597946275%22%20id%3D%22toc-hId-597946275%22%20id%3D%22toc-hId-597946275%22%20id%3D%22toc-hId--804577441%22%3E%3CFONT%20color%3D%22%230000ff%22%3EGranting%20Permissions%20to%20an%20Application%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3EApplication%20registration%20only%20defines%20which%20permission%20the%20application%20requires%20-%20it%20does%20not%20grant%20these%20permissions%20to%20the%20application.%20An%20Azure%20AD%20tenant%20administrator%20must%20explicitly%20grant%20these%20permissions%20by%20making%20a%20call%20to%20the%20admin%20consent%20endpoint.%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fdevelop%2Factive-directory-v2-scopes%23using-the-admin-consent-endpoint%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EReference%20link%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-741719389%22%20id%3D%22toc-hId-1288507749%22%20id%3D%22toc-hId-1288507749%22%20id%3D%22toc-hId-1288507749%22%20id%3D%22toc-hId-741719389%22%3E%3CFONT%20color%3D%22%230000ff%22%3EWhat%20you%20need%3C%2FFONT%3E%3A%3C%2FH3%3E%0A%3CP%3E%3CSTRONG%3EApplication%20Id%3C%2FSTRONG%3E%3A%20the%20application%20ID%20from%20application%20registration%20portal%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ERedirect%20URL%3C%2FSTRONG%3E%3A%20the%20string%20you%20set%20in%20the%20application%20registration%20portal%20for%20authentication%20response%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1810437572%22%20id%3D%22toc-hId--518946714%22%20id%3D%22toc-hId--518946714%22%20id%3D%22toc-hId--518946714%22%20id%3D%22toc-hId--1810437572%22%3E%3CFONT%20color%3D%22%230000ff%22%3EWhat%20you%20need%20to%20do%3A%3C%2FFONT%3E%3C%2FH3%3E%0A%3CP%3EIn%20a%20text%20editor%2C%20create%20following%20URL%20string%3A%3C%2FP%3E%0A%3CP%3E%3CA%20title%3D%22https%3A%2F%2Flogin.microsoftonline.com%2Fcommon%2Fadminconsent%3Fclient_id%3D%26lt%3BApplication%20Id%26gt%3B%26amp%3Bstate%3D12345%26amp%3Bredirect_uri%3D%26lt%3BRedirect%20URL%26gt%3B%22%20href%3D%22https%3A%2F%2Flogin.microsoftonline.com%2Fcommon%2Fadminconsent%3Fclient_id%3D%26lt%3BApplication%2520Id%26gt%3B%26amp%3Bstate%3D12345%26amp%3Bredirect_uri%3D%26lt%3BRedirect%20URL%26gt%3B%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Flogin.microsoftonline.com%2Fcommon%2Fadminconsent%3Fclient_id%3D%3CAPPLICATION%20id%3D%22%22%3E%26amp%3Bstate%3D12345%26amp%3Bredirect_uri%3D%3CREDIRECT%20url%3D%22%22%3E%3C%2FREDIRECT%3E%3C%2FAPPLICATION%3E%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EIn%20a%20web%20browser%2C%20navigate%20to%20this%20URL%2C%20and%20sign-in%20as%20a%20tenant%20administrator%3B%20the%20popup%20dialog%20shows%20the%20list%20of%20permission%20the%20application%20requires%2C%20as%20specified%20in%20the%20application%20registration%20portal.%20%3CBR%20%2F%3E%20Click%20%E2%80%9C%3CSTRONG%3EOK%3C%2FSTRONG%3E%E2%80%9D%20to%20grant%20the%20application%20these%20permissions.%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ENote%3C%2FSTRONG%3E%3A%20this%20step%20%3CU%3Egrants%20permissions%20to%20the%20application%20-%20not%20to%20users%3C%2FU%3E.%20This%20means%20that%20%3CU%3Eall%20users%20belonging%20to%20the%20AAD%20tenant%20that%20using%20this%20application%20will%20be%20granted%20these%20permissions%20-%20even%20non-admin%20users%3C%2FU%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-128886268%22%20id%3D%22toc-hId--529449818%22%20id%3D%22toc-hId--529449818%22%20id%3D%22toc-hId--529449818%22%20id%3D%22toc-hId-128886268%22%3E%3CFONT%20color%3D%22%230000ff%22%3EAssigning%20AAD%20roles%20to%20users%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3EOnce%20an%20application%20is%20granted%20permissions%2C%20everyone%20with%20access%20to%20the%20application%20(i.e.%20members%20of%20the%20AAD%20tenant)%20will%20receive%20the%20granted%20permissions.%20To%20further%20protect%20sensitive%20security%20data%2C%20the%20Microsoft%20Graph%20Security%20API%20also%20requires%20users%20be%20assigned%20the%20Azure%20AD%20%3CSTRONG%3ESecurity%20Reader%3C%2FSTRONG%3E%20role.%3C%2FP%3E%0A%3CP%3EReference%20links%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Factive-directory-assign-admin-roles-azure-portal%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eadmin%20role%3C%2FA%3E%26nbsp%3B%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Factive-directory-users-assign-role-azure-portal%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eassign%20roles%3C%2FA%3E%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-960021809%22%20id%3D%22toc-hId--534051823%22%20id%3D%22toc-hId--534051823%22%20id%3D%22toc-hId--534051823%22%20id%3D%22toc-hId-960021809%22%3E%3CFONT%20color%3D%22%230000ff%22%3EWhat%20you%20need%3A%3C%2FFONT%3E%3C%2FH3%3E%0A%3CP%3EA%20tenant%20admin%20must%20perform%20this%20step%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1592135152%22%20id%3D%22toc-hId-1953461010%22%20id%3D%22toc-hId-1953461010%22%20id%3D%22toc-hId-1953461010%22%20id%3D%22toc-hId--1592135152%22%3E%3CFONT%20color%3D%22%230000ff%22%3EWhat%20you%20need%20to%20do%3A%3C%2FFONT%3E%3C%2FH3%3E%0A%3CP%3EThe%20admin%20must%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ESign-in%20to%20%3CA%20href%3D%22http%3A%2F%2Fportal.azure.com%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Eazure%20portal%3C%2FA%3E%20(%3CA%20href%3D%22http%3A%2F%2Fportal.azure.com%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fportal.azure.com%3C%2FA%3E)%3C%2FLI%3E%0A%3CLI%3EIn%20the%20menu%2C%20select%20%3CSTRONG%3EAzure%20Active%20Directory%20%26gt%3B%20Users%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3ESelect%20the%20name%20of%20the%20desired%20user%3C%2FLI%3E%0A%3CLI%3ESelect%20%3CSTRONG%3EManage%20%26gt%3B%20Directory%20role%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3ESelect%20%E2%80%9CLimited%20administrator%E2%80%9D%2C%20check%20the%20checkbox%20%E2%80%9CSecurity%20reader%E2%80%9D%3C%2FLI%3E%0A%3CLI%3EClick%20on%20the%20%E2%80%9C%3CSTRONG%3ESave%3C%2FSTRONG%3E%E2%80%9D%20button%20to%20save%20the%20change%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH2%20id%3D%22toc-hId-1947626542%22%20id%3D%22toc-hId-16923828%22%20id%3D%22toc-hId-16923828%22%20id%3D%22toc-hId-16923828%22%20id%3D%22toc-hId-1947626542%22%3E%3CFONT%20color%3D%22%230000ff%22%3ECreate%20an%20authentication%20code%3C%2FFONT%3E%3C%2FH2%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdeveloper.microsoft.com%2Fen-us%2Fgraph%2Fdocs%2Fconcepts%2Fauth_v2_user%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EReference%20link%3C%2FA%3E%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1893485518%22%20id%3D%22toc-hId--1661447916%22%20id%3D%22toc-hId--1661447916%22%20id%3D%22toc-hId--1661447916%22%20id%3D%22toc-hId-1893485518%22%3E%3CFONT%20color%3D%22%230000ff%22%3EWhat%20you%20need%3A%3C%2FFONT%3E%3C%2FH3%3E%0A%3CP%3E%3CSTRONG%3EApplication%20ID%3C%2FSTRONG%3E%3A%20the%20application%20ID%20from%20application%20registration%20portal%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ERedirect%20URL%3C%2FSTRONG%3E%3A%20where%20the%20authentication%20response%20from%20AAD%20is%20sent%20to.%20%3CBR%20%2F%3E%20To%20begin%2C%20you%20can%20use%20%3CA%20href%3D%22http%3A%2F%2Flocalhost%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Flocalhost%3C%2FA%3E%20or%20the%20test%20client%20web%20app%20homepage%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EApplication%20Key%20%3C%2FSTRONG%3E(optional)%3A%20the%20key%20of%20the%20application%2C%20used%20when%20developing%20an%20application%20that%20will%20use%20application-only%20authentication%20code%20(i.e.%20will%20not%20support%20user%20delegated%20authentication)%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--658671443%22%20id%3D%22toc-hId-826064917%22%20id%3D%22toc-hId-826064917%22%20id%3D%22toc-hId-826064917%22%20id%3D%22toc-hId--658671443%22%3E%3CFONT%20color%3D%22%230000ff%22%3EWhat%20you%20need%20to%20do%3A%3C%2FFONT%3E%3C%2FH3%3E%0A%3CP%3EThere%20are%20code%20samples%20demonstrating%20on%20how%20to%20get%20authentication%20tokens%20for%20in%20various%20kinds%20of%20applications%2C%20authentication%20libraries%20are%20also%20provided.%3C%2FP%3E%0A%3CTABLE%20width%3D%22630%22%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22192%22%3E%3CP%3E%3CSTRONG%3EType%20of%20applications%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22438%22%3E%3CP%3E%3CSTRONG%3EAuthentication%20Library%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22192%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fdevelop%2Fguidedsetups%2Factive-directory-ios%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EDesktop%20apps%20-%20iOS%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22438%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzureAD%2Fmicrosoft-authentication-library-for-objc%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EMSAL.framework%3A%20Microsoft%20Authentication%20Library%20Preview%20for%20iOS%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22192%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fdevelop%2Fguidedsetups%2Factive-directory-android%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EDesktop%20apps%20-%20Android%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22438%22%3E%3CP%3E%3CA%20href%3D%22http%3A%2F%2Fjavadoc.io%2Fdoc%2Fcom.microsoft.identity.client%2Fmsal%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EMicrosoft%20Authentication%20Library%20(MSAL)%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22192%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fdevelop%2Fguidedsetups%2Factive-directory-windesktop%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EDesktop%20apps%20-%20.Net%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22438%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwww.nuget.org%2Fpackages%2FMicrosoft.Identity.Client%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EMicrosoft%20Authentication%20Library%20(MSAL)%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22192%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fdevelop%2Fguidedsetups%2Factive-directory-javascriptspa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EWeb%20apps%20-%20JavaScript%20SPA%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22438%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzureAD%2Fmicrosoft-authentication-library-for-js%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EMicrosoft%20Authentication%20Library%20for%20JavaScript%20Preview%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22192%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fdevelop%2Fguidedsetups%2Factive-directory-aspnetwebapp%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EWeb%20apps%20-%20.Net%20Web%20Server%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22438%22%3E%3CP%3EOpenIdConnection%2C%20Cookies%2C%20SystemWeb%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22192%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fdevelop%2Factive-directory-v2-devquickstarts-node-web%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EWeb%20apps%20-%20NodeJS%20Web%20App%3C%2FA%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20width%3D%22438%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20the%20applications%20do%20not%20use%20any%20of%20the%20existing%20libraries%2C%20please%20follow%20this%20%3CA%20href%3D%22https%3A%2F%2Fdeveloper.microsoft.com%2Fen-us%2Fgraph%2Fdocs%2Fconcepts%2Fauth_v2_user%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Edoc%3C%2FA%3E%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EGet%20a%20code%20from%20AAD.%20The%20query%20to%20call%20contains%20parameter%20for%20Application%20ID%2C%20Redirect%20URl%20and%20%3CSTRONG%3Erequired%20permissions%3C%2FSTRONG%3E.%3C%2FLI%3E%0A%3CLI%3EUse%20the%20code%20to%20get%20an%20access%20token%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EIf%20you%20use%20OpenId%20Connect%20library%2C%20please%20see%20this%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Farchitecture%2Fmultitenant-identity%2Fauthenticate%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Edoc%3C%2FA%3E%20and%20call%20app.UseOpenIdConnectAuthentication()%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ENote%3A%20%3C%2FSTRONG%3EIn%20the%20library%2C%20when%20requesting%20user%20delegated%20authentication%20tokens%2C%20the%20parameter%20for%20the%20library%20is%20%E2%80%9CRequested%20Scopes%E2%80%9D.%20Use%20%E2%80%9CUser.Read%E2%80%9D%20for%20this%20parameter%20instead%20of%20using%20whatever%20the%20registered%20application%20requires.%20The%20%E2%80%9CRequested%20Scopes%E2%80%9D%20parameter%20does%20NOT%20affect%20the%20permissions%20contained%20in%20the%20returned%20authentication%20tokens%2C%20since%20these%20are%20determined%20by%20the%20permissions%20that%20the%20tenant%20admin%20granted%20the%20application.%3C%2FP%3E%0A%3CP%3EUsing%20.Net%20MSAL%20library%20as%20example%3A%3C%2FP%3E%0A%3CP%3Evar%20accessToken%20%3D%20(await%20client.AcquireTokenAsync(scopes)).AccessToken%3B%3C%2FP%3E%0A%3CP%3ENote%20that%20scopes%20in%20above%20example%20should%20be%20minimum%20permission%20such%20as%20%E2%80%9CUser.Read%E2%80%9D.%20However%20the%20returned%20access%20token%20can%20contains%20scopes%20such%20as%20%E2%80%9CUser.Read.All%E2%80%9D%20or%20%E2%80%9CUser.ReadWrite.All%E2%80%9D%20which%20were%20granted%20by%20tenant%20admin%20for%20current%20user%20tenant.%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1084138892%22%20id%3D%22toc-hId--981389546%22%20id%3D%22toc-hId--981389546%22%20id%3D%22toc-hId--981389546%22%20id%3D%22toc-hId-1084138892%22%3E%3CFONT%20color%3D%22%230000ff%22%3EWhat%20You%20receive%3A%3C%2FFONT%3E%3C%2FH3%3E%0A%3CP%3EA%20token%20(string)%20is%20returned%20by%20AAD%20that%20contains%20your%20authentication%20info%20and%20the%20permissions%20required%20by%20the%20application.%20Assign%20this%20token%20to%20the%20HTTP%20header%20as%20a%20bearer%20token%2C%20as%20in%20the%20code%20below%3A%3C%2FP%3E%0A%3CP%3Erequest.Headers.Authorization%20%3D%20new%20AuthenticationHeaderValue(%22bearer%22%2C%20accessToken)%3B%3C%2FP%3E%0A%3CP%3EMicrosoft%20Graph%20will%20validate%20the%20information%20contained%20in%20this%20token%20and%20grant%2C%20or%20reject%2C%20access.%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20view%20claims%20contained%20in%20the%20returned%20token%2C%20use%20NuGet%20library%20System.IdentityModel.Tokens.Jwt.%3C%2FP%3E%0A%3CP%3EJwtSecurityTokenHandler%20tokenHandler%20%3D%20new%20JwtSecurityTokenHandler()%3B%3C%2FP%3E%0A%3CP%3Evar%20securityToken%20%3D%20tokenHandler.ReadToken(accessToken)%20as%20JwtSecurityToken%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1468018069%22%20id%3D%22toc-hId-1506123287%22%20id%3D%22toc-hId-1506123287%22%20id%3D%22toc-hId-1506123287%22%20id%3D%22toc-hId--1468018069%22%3E%3CFONT%20color%3D%22%230000ff%22%3EIn%20case%20you%20encounter%20an%20Authentication%20failure%3C%2FFONT%3E%3C%2FH3%3E%0A%3CP%3EThe%20response%20from%20Microsoft%20Graph%20contains%20a%20header%20called%20client-request-id%2C%20which%20is%20a%20GUID.%20%3CBR%20%2F%3E%20If%20access%20is%20denied%2C%20please%20specify%20this%20GUID%20when%20seeking%20support%2C%20so%20we%20can%20help%20investigate%20the%20cause%20of%20this%20authentication%20failure.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-298389%22%20slang%3D%22en-US%22%3ERe%3A%20Authorization%20and%20Microsoft%20Graph%20Security%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-298389%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Brendon%2C%3C%2FP%3E%0A%3CP%3EYou%20can%20download%20the%20Auth%20Helper%20sample%20code%20here%3A%20%3CBR%20%2F%3E%3CA%20title%3D%22Graph-Security-API-Auth-Sample%22%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoftgraph%2FGraph-Security-API-Auth-Sample%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fmicrosoftgraph%2FGraph-Security-API-Auth-Sample%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EWhen%20you%20compile%20and%20run%20the%20application%2C%20you'll%20see%20three%20tabs%20in%20the%20app's%20UI%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%26nbsp%3BUser%20delegated%20authorization%3C%2FLI%3E%0A%3CLI%3E%3CU%3E%3CSTRONG%3EApplication-only%20authorization%3C%2FSTRONG%3E%3C%2FU%3E%3C%2FLI%3E%0A%3CLI%3EHelp%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3ESelect%20the%20second%2C%20and%20provide%20the%20AppId%20and%20AppKey%20(Secret)%20-%20after%20verifying%20that%20you%20defined%20App-Only%20permissions%20in%20the%20app%20registration%20(%3CA%20title%3D%22App%20Registration%22%20href%3D%22http%3A%2F%2Fapps.dev.microsoft.com%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ehttp%3A%2F%2Fapps.dev.microsoft.com%3C%2FA%3E)%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20hope%20this%20solves%20the%20issue%20for%20you%3C%2FP%3E%0A%3CP%3EMichael%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-297895%22%20slang%3D%22en-US%22%3ERe%3A%20Authorization%20and%20Microsoft%20Graph%20Security%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-297895%22%20slang%3D%22en-US%22%3E%3CP%3EMichael%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20appreciate%20your%20reply!%20I%20was%20still%20not%20able%20to%20find%20a%20code%20example%20of%20app%20authenticate.%20All%20of%20the%20listed%20example%20only%20contain%20code%20for%20user%20it%20seems%20unless%20I%20keep%20over%20looking%20something.%20I%20might%20just%20be%20misunderstanding%20something%20due%20to%20inexperience%20but%20I%20appreciate%20your%20help%20thus%20far%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-297158%22%20slang%3D%22en-US%22%3ERe%3A%20Authorization%20and%20Microsoft%20Graph%20Security%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-297158%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Brandon%2C%3C%2FP%3E%0A%3CP%3EYes%2C%20App-only%20AuthNZ%20is%20also%20supported%20-%20and%20covered%20in%20the%20documentation%20-%20please%20note%20that%20this%20approach%20assumes%20that%20Role%20Based%20Access%20Control%20(RBAC)%20will%20be%20implemented%20by%20the%20calling%20application.%3C%2FP%3E%0A%3CP%3EThe%20Graph%20Security%20API%20GitHub%20code%20samples%20include%20a%20%3CA%20title%3D%22C%23%20Auth%20Helper%20App%22%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoftgraph%2FGraph-Security-API-Auth-Sample%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EC%23%20Auth%20Helper%20App%20%3C%2FA%3Ethat%20will%20let%20you%20test%20and%20see%20the%20contents%20of%20the%20Auth%20token%20-%20both%20for%20User%2FDelegated%20or%20for%20App-only%20(different%20tabs).%3C%2FP%3E%0A%3CP%3EAlso%20make%20sure%20you%20specify%20the%20required%20scopes%20for%20App-Only%20during%20app%20registration%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHope%20this%20helps%3C%2FP%3E%0A%3CP%3EMichael%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-296903%22%20slang%3D%22en-US%22%3ERe%3A%20Authorization%20and%20Microsoft%20Graph%20Security%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-296903%22%20slang%3D%22en-US%22%3E%3CP%3EHey%20Michael%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20article%20is%20really%20helpful.%20I%20am%20currently%20getting%20the%20auth%20token%20and%20sending%20the%20request%20to%20the%20Graph%20API%20via%20Microsoft%20Flow%20but%20want%20to%20move%20the%20functionality%20to%20an%20Azure%20function.%20Is%20there%20a%20javascipt%20example%20for%20authenticating%20and%20querying%20the%20Graph%20API%20using%20an%20app%20registration%20and%20not%20user%20auth%3F%20Much%20appreciated!%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-271777%22%20slang%3D%22en-US%22%3ERe%3A%20Authorization%20and%20Microsoft%20Graph%20Security%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-271777%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Michale%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20very%20much%20for%20coming%20back%20to%20me.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20the%20user%20and%20the%20app%20appear%20to%20have%20the%20appropriate%20roles%2Fpermissions.%20I%20even%20went%26nbsp%3Bso%20far%20as%20granting%20the%20app%20all%20possible%20permissions%20and%20giving%20the%20user%20all%20possible%20roles.%20I%20have%20created%20new%20test%20users%20and%20new%20app%20registrations%20and%20tried%20many%20other%20things.%20Still%2C%20I'm%26nbsp%3Bgetting%20a%20403.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20makes%20me%20think%20it's%20somehow%20not%20a%20problem%20with%20permissions%20but%20some%20other%20configuration%20issue%20with%20the%20app%2C%26nbsp%3Bad%20or%20tenant.%20I'm%20using%20our%20companies%20sandbox%20tenant%2C%20so%20other%20engineers%26nbsp%3Bare%20always%20playing%20with%20the%20config.%20I%20plan%20on%20trying%20it%20out%20on%20a%20different%20tenant%26nbsp%3Bonce%20one%20becomes%20available%20to%20me.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAre%20you%20aware%20of%20any%20configuration%20other%20than%20permissions%20or%20roles%20which%26nbsp%3Bmight%20cause%20a%20403%20response%20from%20this%20endpoint%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20again.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMatt%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EEdit%2016%20Oct%20'18%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20I%20have%20tried%20another%20tenant%20and%20am%20facing%20the%20same%20issue...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20think%20it%20must%20be%20a%20problem%20with%20the%20configuration%20of%20my%20app%20since%20all%20the%20users%20I%20have%20tried%20have%20access%20to%20the%20secure%20score%20via%20other%20means%20(Web%20portal%20and%20Graph%20explorer%20app).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20app%20is%20a%20JS%20SPA%20using%20the%20MSAL-Angular%20library%26nbsp%3Band%20the%20implicit%20auth%20flow.%20The%20MSAL%20config%20is%20as%20follows%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3EconsentScopes%3A%20%5B%3CBR%20%2F%3E%26nbsp%3B%20'User.Read'%2C%3CBR%20%2F%3E%26nbsp%3B%20'SecurityEvents.Read.All'%3CBR%20%2F%3E%5D%2C%3CBR%20%2F%3EprotectedResourceMap%3A%20%5B%3CBR%20%2F%3E%26nbsp%3B%20%5B%3CBR%20%2F%3E%20%20%20%20'%3CA%20href%3D%22https%3A%2F%2Fgraph.microsoft.com%2Fbeta%2Forganization%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgraph.microsoft.com%2Fbeta%2Forganization%3C%2FA%3E'%2C%3CBR%20%2F%3E%20%20%20%20%5B'User.Read'%5D%3CBR%20%2F%3E%20%20%5D%2C%3CBR%20%2F%3E%26nbsp%3B%20%5B%3CBR%20%2F%3E%20%20%20%20'%3CA%20href%3D%22https%3A%2F%2Fgraph.microsoft.com%2Fbeta%2Fsecurity%2FsecureScores%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgraph.microsoft.com%2Fbeta%2Fsecurity%2FsecureScores%3C%2FA%3E'%2C%3CBR%20%2F%3E%20%20%20%20%5B'SecurityEvents.Read.All'%5D%3CBR%20%2F%3E%20%20%5D%3CBR%20%2F%3E%5D%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20tried%20many%20other%20configurations%20but%20this%20is%20the%20simplest%20I%20believe%20should%20work.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20ideas%20what%20I%20might%20be%20doing%20wrong%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20again.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMatt%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-271671%22%20slang%3D%22en-US%22%3ERe%3A%20Authorization%20and%20Microsoft%20Graph%20Security%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-271671%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Matt%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20access%20SecureScore%2C%20you%20need%20to%20meet%20the%20product's%20Role-Based%20Access%20Control%20(RBAC)%20-%20in%20this%20case%20to%20belong%20to%20one%20of%20the%20groups%20listed%20below%20-%20broken%20out%20into%20Read%20access%20and%20Write%20access%3A%3C%2FP%3E%0A%3CP%3E(for%20convenience%2C%20listing%20both%20required%20Graph%20Scopes%20and%20AAD%20Roles)%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CU%3E%3CSTRONG%3ERead%3C%2FSTRONG%3E%3C%2FU%3E%3A%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EScopes%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EGraphPermissions.SecurityEventsReadAllScope%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSTRONG%3ERoles%3C%2FSTRONG%3E%20%26nbsp%3B%20%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EAadRoles.ExchangeServiceAdministratorRole%3C%2FLI%3E%0A%3CLI%3EAadRoles.SharePointServiceAdministratorRole%3C%2FLI%3E%0A%3CLI%3EAadRoles.HelpdeskAdministratorRole%3C%2FLI%3E%0A%3CLI%3EAadRoles.UserAccountAdministratorRole%3C%2FLI%3E%0A%3CLI%3EAadRoles.ServiceSupportAdministratorRole%3C%2FLI%3E%0A%3CLI%3EAadRoles.SecurityReaderRole%3C%2FLI%3E%0A%3CLI%3EAadRoles.SecurityAdministratorRole%3C%2FLI%3E%0A%3CLI%3EAadRoles.CompanyAdministratorRole%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CU%3E%3CSTRONG%3EWrite%20(Patch)%3A%3C%2FSTRONG%3E%3C%2FU%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EScopes%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EGraphPermissions.SecurityEventsReadWriteAllScope%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSTRONG%3ERoles%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EAadRoles.SecurityAdministratorRole%3C%2FLI%3E%0A%3CLI%3EAadRoles.ExchangeServiceAdministratorRole%3C%2FLI%3E%0A%3CLI%3EAadRoles.SharePointServiceAdministratorRole%3C%2FLI%3E%0A%3CLI%3EAadRoles.CompanyAdministratorRole%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EHope%20this%20helps%20-%20great%20if%20you%20could%20confirm%20after%20applying%20the%20above%3C%2FP%3E%0A%3CP%3EMichael%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-271575%22%20slang%3D%22en-US%22%3ERe%3A%20Authorization%20and%20Microsoft%20Graph%20Security%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-271575%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20trying%20to%20access%20the%20secure%20score%20endpoint%20via%20my%20app.%20The%20app%20and%20user%20have%20the%20required%20permissions%20as%20per%20this%20post%2C%20however%2C%20I%20am%20still%20getting%20a%20403%20when%20attempting%20to%20call%20any%20of%20the%20security%20endpoints.%20The%20app%20is%20able%20to%20successfully%20call%20other%20graph%20endpoints.%3CBR%20%2F%3E%3CBR%20%2F%3EIs%20it%20possible%20to%20get%20more%20info%20about%20exactly%20why%20access%20is%20denied%3F%20The%20response%20body%20just%20states%20that%20the%26nbsp%3Btoken%20or%20user%20do%20not%20have%20required%26nbsp%3Bpermissions.%20An%20example%20request%20id%20is%3A%20%22b58137f1-37ea-40fb-93bb-20497b922df6%22.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20same%20user%20is%20able%20to%20make%20requests%20to%20the%20endpoint%20just%20fine%20using%20the%20Graph%20Explorer%20app.%20I%20have%20also%20compared%20the%20token%20permissions%20in%20the%20scp%26nbsp%3Bclaim%20and%20given%20my%20app%20(and%20token)%20identical%20permissions%20but%20still%2C%20I%20get%20403!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHave%20been%20struggling%20with%20this%20for%20some%20time%20now.%20Seemingly%20everything%20is%20configured%20correctly.%20Anything%20to%20shed%20some%20more%20light%20on%20exactly%20what%20is%20required%20would%20be%20greatly%20appreciated.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%3C%2FP%3E%3CP%3EMatt%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1033708%22%20slang%3D%22en-US%22%3ERe%3A%20Authorization%20and%20Microsoft%20Graph%20Security%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1033708%22%20slang%3D%22en-US%22%3E%3CP%3EHey%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F31297%22%20target%3D%22_blank%22%3E%40Michael%20Shalev%3C%2FA%3E%2C%20thank%20you%20for%20the%20insight%20on%20api%20authorizations!%3C%2FP%3E%3CP%3EAre%20there%20any%20security%20implications%20to%20be%20wary%20of%20when%20granting%20application-level%20authorization%20for%20an%20application%3F%20or%20is%20this%20merely%20the%20same%20authorization%20level%20as%20the%20delegated%20privileges%20but%20without%20the%20need%20for%20a%20user%20sign-in%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1036777%22%20slang%3D%22en-US%22%3ERe%3A%20Authorization%20and%20Microsoft%20Graph%20Security%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1036777%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F469447%22%20target%3D%22_blank%22%3E%40jyisas%3C%2FA%3E%26nbsp%3BThere%20are%20significant%20security%20considerations%20when%20using%20application%20auth%2C%20specifically%3A%20this%20will%20bypass%20role%20based%20access%20control%20(RBAC)%20enforcement%20which%20is%20defined%20and%20enforced%20at%20user%20level%2C%20i.e%20when%20User%2FDelegated%20auth%20mode%20is%20used.%3C%2FP%3E%0A%3CP%3EThe%20recommended%20practice%20when%20using%20app-level%20auth%20would%20be%20to%20enforce%20necessary%20access%20control%20in%20the%20app%20calling%20the%20Graph%20Security%20API%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1267544%22%20slang%3D%22en-US%22%3ERe%3A%20Authorization%20and%20Microsoft%20Graph%20Security%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1267544%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F31297%22%20target%3D%22_blank%22%3E%40Michael%20Shalev%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt's%20unfortunate%26nbsp%3Bthat%20there%20is%20no%20option%20%26nbsp%3Bto%20use%20the%20%22Security%20Operator%22%20role%20just%20for%20the%20implementation%20use%20cases%20where%20there%20is%20only%20the%20requirement%20to%20read%20and%26nbsp%3Bupdate%20(e.g.%20close)%20MS%20Graph%20Security%20API%20security%20alerts%20under%20a%20delegated%20permissions%20scenario.%20In%20that%20case%20the%20only%20option%20available%20seems%20to%20require%20the%20%22Security%20Admin%22%20role%20to%20be%20assigned.%20At%20the%20same%20time%20there%20are%20also%20challenges%20with%20monitoring%20and%20alerting%20options%20if%20we%20use%20app-level%20auth.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

Understanding authorization when calling the Microsoft Graph Security API

High-level summary: Security data accessible via the Microsoft Graph Security API is very sensitive and is protected using both permissions (aka scopes) and Azure AD (AAD) roles.

Microsoft Graph Security API supports two types of application authorization:

  • Application-level authorization, where there is no signed-in user (e.g. a SIEM scenario).
    Here the permissions/scopes granted to the application determine authorization.
    Note: this option can also support cases where Role-Based Access Control (aka RBAC) is managed by the application.
  • User delegated authorization, where a user who is a member of the AAD tenant is signed in.
    Here the user must be a member of an AAD Limited Admin role - either Security Reader or Securty Administrator, in addition to the application having been granted the required permissions

We distinguish between two types of client applications: the Microsoft Graph Explorer, and custom client applications.

If calling from Graph Explorer:

  • The AAD tenant admin must explicitly grant consent for the requested permissions to the Graph Explorer application
  • The user must be a member of the Security Reader Limited Admin role in AAD (either Security Reader or Security Administrator)
  • Note: Graph Explorer does not support application-level authorization

If calling from a custom/your own application:

  • The AAD tenant admin must explicitly grant consent to your application. This is required both for application-level authorization as well as for user delegated authorization
  • If using user delegated authorization, the user must be a member of the Security Reader or Security Administrator Limited Admin role in AAD

The following section contains a detailed technical explanation of using the Authorization mechanisms.

 

Managing authorization in Microsoft Graph Security API client applications

Security data provided via the Microsoft Graph Security API is sensitive and must be protected by appropriate authentication and authorization mechanisms. To register and create a client application that can access the Microsoft Graph Security API, the following steps must be performed:

Who

Action

Application developer or owner

Register application as an enterprise application

Tenant Admin

Grant permissions to the application

Tenant Admin

Assign Limited Administrator roles to users

Application developer

Sign-in as the user and use application to access Graph Security API

 

To clarify:

  • Application registration only defines which permissions the application needs in order to run.
    It does NOT grant these permissions to the application.
  • The Azure AD tenant administrator MUST explicitly grant the permissions to the application.
    This MUST be done per tenant and performed every time the application permissions are changed in the application registration portal.
  • Let’s assume we have: an application: App, two AAD tenants: T1 and T2, and two scopes, or permissions: P1 and P2.
    • Application App registered to require permission P1
    • When users in tenant T1 get an AAD token for this application, the token does not contain any permissions (see next bullet)
    • The AAD Admin of tenant T1 explicitly grants permissions to the application App. From this moment on, when users in tenant T1 get an AAD token for App, it will contain permission P1
    • When users in tenant T2 get an AAD token for application App, the token does not contain any permissions - because the admin of tenant T2 did not yet grant permissions to App.
      The procedure of granting permission must be performed per tenant and per application
    • The application App has its registration changed to now require permissions P1 and P2
    • When users in tenant T1 get an AAD token for App, it only contains permission P1. Permissions granted to an application are recorded as snapshots of what was granted -
      they do not change automatically after the application registration (permission) changes
    • The admin of tenant T2 grants permissions P1 and P2 to the application App.
      From this moment on, when users in tenant T2 get AAD token for App, the token will contain permissions P1 and P2

Note: for the same application (App), the AAD token for the application in tenant T1 and that for the application in tenant T2 contain different permissions, since the tenant admins each granted different permissions to the application (App)

  • To make App work again in tenant T1, the admin of tenant T1 must explicitly grant permissions P1 and P2 to the application (App)

Register an Application in v2.0 endpoint

Reference link

What you need:

Application Name: a string used for the application name

Redirect URL: where the authentication response from AAD is sent to.
To begin with, you can use the test client web app homepage.

Required Permissions: the permissions that your application requires to be able to call Microsoft Graph

What you need to do:

  1. Go to https://apps.dev.microsoft.com/ and sign in.
    Note: there is no need to be a tenant admin. You will be redirected to “My applications” list
  2. Click the “Add an app” button, and enter an Application Name to create a new application
  3. It will navigate to the registration page for the new application.
    Click “Add Platform”, choose “Web”. In the Redirect URL, enter the Redirect URL.
  4. Go to section “Microsoft Graph Permissions” and under “Delegated Permissions”, click the “Add” button. A popup dialog appears; choose required permissions (aka scopes).
    See this document for detailed scopes. The Microsoft Graph Security API requires “SecurityEvents.Read.All” scope for GET queries, and “SecurityEvents.ReadWrite.All” scope for PATCH/POST queries.
  5. Scroll down to the bottom of the page and click on the “Save” button

What to save for future steps:

  • Application Id
  • Redirect URL
  • List of required permissions 

Granting Permissions to an Application

Application registration only defines which permission the application requires - it does not grant these permissions to the application. An Azure AD tenant administrator must explicitly grant these permissions by making a call to the admin consent endpoint.

Reference link 

What you need:

Application Id: the application ID from application registration portal

Redirect URL: the string you set in the application registration portal for authentication response

What you need to do:

In a text editor, create following URL string:

https://login.microsoftonline.com/common/adminconsent?client_id=<Application Id>&state=12345&redirec...

In a web browser, navigate to this URL, and sign-in as a tenant administrator; the popup dialog shows the list of permission the application requires, as specified in the application registration portal.
Click “OK” to grant the application these permissions.

Note: this step grants permissions to the application - not to users. This means that all users belonging to the AAD tenant that using this application will be granted these permissions - even non-admin users 

Assigning AAD roles to users

Once an application is granted permissions, everyone with access to the application (i.e. members of the AAD tenant) will receive the granted permissions. To further protect sensitive security data, the Microsoft Graph Security API also requires users be assigned the Azure AD Security Reader role.

Reference links: admin role  assign roles

What you need:

A tenant admin must perform this step

What you need to do:

The admin must:

  • Sign-in to azure portal (http://portal.azure.com)
  • In the menu, select Azure Active Directory > Users
  • Select the name of the desired user
  • Select Manage > Directory role
  • Select “Limited administrator”, check the checkbox “Security reader”
  • Click on the “Save” button to save the change

Create an authentication code

Reference link

What you need:

Application ID: the application ID from application registration portal

Redirect URL: where the authentication response from AAD is sent to.
To begin, you can use http://localhost or the test client web app homepage

Application Key (optional): the key of the application, used when developing an application that will use application-only authentication code (i.e. will not support user delegated authentication)

What you need to do:

There are code samples demonstrating on how to get authentication tokens for in various kinds of applications, authentication libraries are also provided.

Type of applications

Authentication Library

Desktop apps - iOS

MSAL.framework: Microsoft Authentication Library Preview for iOS

Desktop apps - Android

Microsoft Authentication Library (MSAL)

Desktop apps - .Net

Microsoft Authentication Library (MSAL)

Web apps - JavaScript SPA

Microsoft Authentication Library for JavaScript Preview

Web apps - .Net Web Server

OpenIdConnection, Cookies, SystemWeb

Web apps - NodeJS Web App

 

 

If the applications do not use any of the existing libraries, please follow this doc

  1. Get a code from AAD. The query to call contains parameter for Application ID, Redirect URl and required permissions.
  2. Use the code to get an access token

If you use OpenId Connect library, please see this doc and call app.UseOpenIdConnectAuthentication()

Note: In the library, when requesting user delegated authentication tokens, the parameter for the library is “Requested Scopes”. Use “User.Read” for this parameter instead of using whatever the registered application requires. The “Requested Scopes” parameter does NOT affect the permissions contained in the returned authentication tokens, since these are determined by the permissions that the tenant admin granted the application.

Using .Net MSAL library as example:

var accessToken = (await client.AcquireTokenAsync(scopes)).AccessToken;

Note that scopes in above example should be minimum permission such as “User.Read”. However the returned access token can contains scopes such as “User.Read.All” or “User.ReadWrite.All” which were granted by tenant admin for current user tenant.

What You receive:

A token (string) is returned by AAD that contains your authentication info and the permissions required by the application. Assign this token to the HTTP header as a bearer token, as in the code below:

request.Headers.Authorization = new AuthenticationHeaderValue("bearer", accessToken);

Microsoft Graph will validate the information contained in this token and grant, or reject, access. 

To view claims contained in the returned token, use NuGet library System.IdentityModel.Tokens.Jwt.

JwtSecurityTokenHandler tokenHandler = new JwtSecurityTokenHandler();

var securityToken = tokenHandler.ReadToken(accessToken) as JwtSecurityToken;

  

In case you encounter an Authentication failure

The response from Microsoft Graph contains a header called client-request-id, which is a GUID.
If access is denied, please specify this GUID when seeking support, so we can help investigate the cause of this authentication failure.

9 Replies

Hi,

 

I'm trying to access the secure score endpoint via my app. The app and user have the required permissions as per this post, however, I am still getting a 403 when attempting to call any of the security endpoints. The app is able to successfully call other graph endpoints.

Is it possible to get more info about exactly why access is denied? The response body just states that the token or user do not have required permissions. An example request id is: "b58137f1-37ea-40fb-93bb-20497b922df6".

 

The same user is able to make requests to the endpoint just fine using the Graph Explorer app. I have also compared the token permissions in the scp claim and given my app (and token) identical permissions but still, I get 403!

 

Have been struggling with this for some time now. Seemingly everything is configured correctly. Anything to shed some more light on exactly what is required would be greatly appreciated.

 

Thanks,

Matt

Hi Matt,

 

To access SecureScore, you need to meet the product's Role-Based Access Control (RBAC) - in this case to belong to one of the groups listed below - broken out into Read access and Write access:

(for convenience, listing both required Graph Scopes and AAD Roles):

 

Read:

Scopes

 

  • GraphPermissions.SecurityEventsReadAllScope

Roles    

  • AadRoles.ExchangeServiceAdministratorRole
  • AadRoles.SharePointServiceAdministratorRole
  • AadRoles.HelpdeskAdministratorRole
  • AadRoles.UserAccountAdministratorRole
  • AadRoles.ServiceSupportAdministratorRole
  • AadRoles.SecurityReaderRole
  • AadRoles.SecurityAdministratorRole
  • AadRoles.CompanyAdministratorRole

 

Write (Patch):

Scopes:

  • GraphPermissions.SecurityEventsReadWriteAllScope

Roles:

  • AadRoles.SecurityAdministratorRole
  • AadRoles.ExchangeServiceAdministratorRole
  • AadRoles.SharePointServiceAdministratorRole
  • AadRoles.CompanyAdministratorRole

Hope this helps - great if you could confirm after applying the above

Michael

Hi Michale,

 

Thanks very much for coming back to me.

 

So the user and the app appear to have the appropriate roles/permissions. I even went so far as granting the app all possible permissions and giving the user all possible roles. I have created new test users and new app registrations and tried many other things. Still, I'm getting a 403.

 

This makes me think it's somehow not a problem with permissions but some other configuration issue with the app, ad or tenant. I'm using our companies sandbox tenant, so other engineers are always playing with the config. I plan on trying it out on a different tenant once one becomes available to me.

 

Are you aware of any configuration other than permissions or roles which might cause a 403 response from this endpoint?

 

Thanks again.

 

Matt

 

Edit 16 Oct '18:

 

So I have tried another tenant and am facing the same issue...

 

I think it must be a problem with the configuration of my app since all the users I have tried have access to the secure score via other means (Web portal and Graph explorer app).

 

The app is a JS SPA using the MSAL-Angular library and the implicit auth flow. The MSAL config is as follows:

 

consentScopes: [
  'User.Read',
  'SecurityEvents.Read.All'
],
protectedResourceMap: [
  [
'https://graph.microsoft.com/beta/organization',
['User.Read']
],
  [
'https://graph.microsoft.com/beta/security/secureScores',
['SecurityEvents.Read.All']
]
]

 

I have tried many other configurations but this is the simplest I believe should work.

 

Any ideas what I might be doing wrong?

 

Thanks again.

 

Matt

Hi Brandon,

Yes, App-only AuthNZ is also supported - and covered in the documentation - please note that this approach assumes that Role Based Access Control (RBAC) will be implemented by the calling application.

The Graph Security API GitHub code samples include a C# Auth Helper App that will let you test and see the contents of the Auth token - both for User/Delegated or for App-only (different tabs).

Also make sure you specify the required scopes for App-Only during app registration 

 

Hope this helps

Michael

Michael,

 

I appreciate your reply! I was still not able to find a code example of app authenticate. All of the listed example only contain code for user it seems unless I keep over looking something. I might just be misunderstanding something due to inexperience but I appreciate your help thus far

Hi Brendon,

You can download the Auth Helper sample code here:
https://github.com/microsoftgraph/Graph-Security-API-Auth-Sample

When you compile and run the application, you'll see three tabs in the app's UI:

  •  User delegated authorization
  • Application-only authorization
  • Help

Select the second, and provide the AppId and AppKey (Secret) - after verifying that you defined App-Only permissions in the app registration (http://apps.dev.microsoft.com

 

I hope this solves the issue for you

Michael

Hey @Michael Shalev, thank you for the insight on api authorizations!

Are there any security implications to be wary of when granting application-level authorization for an application? or is this merely the same authorization level as the delegated privileges but without the need for a user sign-in?

@jyisas There are significant security considerations when using application auth, specifically: this will bypass role based access control (RBAC) enforcement which is defined and enforced at user level, i.e when User/Delegated auth mode is used.

The recommended practice when using app-level auth would be to enforce necessary access control in the app calling the Graph Security API

@Michael Shalev

 

It's unfortunate that there is no option  to use the "Security Operator" role just for the implementation use cases where there is only the requirement to read and update (e.g. close) MS Graph Security API security alerts under a delegated permissions scenario. In that case the only option available seems to require the "Security Admin" role to be assigned. At the same time there are also challenges with monitoring and alerting options if we use app-level auth.