SOLVED

Best example for getting the Graph API bearer token in SPFX?

%3CLINGO-SUB%20id%3D%22lingo-sub-101281%22%20slang%3D%22en-US%22%3EBest%20example%20for%20getting%20the%20Graph%20API%20bearer%20token%20in%20SPFX%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-101281%22%20slang%3D%22en-US%22%3E%3CP%3EWhat%20is%20the%20best%20solution%20that%20currently%20shows%20how%20to%20get%20the%20Graph%20API%20bearer%20token%20from%20a%20SharePoint%20SPFX%20app%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EADAL.JS%20doesnt%20work%20in%20the%20modern%20Script%20Editor%20Web%20Part%20by%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F34%22%20target%3D%22_blank%22%3E%40Mikael%20Svenson%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20want%20to%20hopefully%20re-use%20my%20existing%20Javascript%20Graph%20API%20functions%2C%20i%20just%20need%20the%20best%20way%20to%20get%20the%20bearer%20token%2C%20and%20then%20muddle%20through%20working%20in%20my%20existing%20functions.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-101281%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAPIs%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-101359%22%20slang%3D%22en-US%22%3ERe%3A%20Best%20example%20for%20getting%20the%20Graph%20API%20bearer%20token%20in%20SPFX%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-101359%22%20slang%3D%22en-US%22%3E%3CA%20href%3D%22https%3A%2F%2Fdev.office.com%2Fsharepoint%2Fdocs%2Fspfx%2Fweb-parts%2Fguidance%2Fcall-microsoft-graph-from-your-web-part%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdev.office.com%2Fsharepoint%2Fdocs%2Fspfx%2Fweb-parts%2Fguidance%2Fcall-microsoft-graph-from-your-web-part%3C%2FA%3E%20or%20if%20you%20can%20make%20due%20with%20access%20via%20Group.%20permissions%2C%20then%20use%20GraphHttpClient.%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20other%20option%20is%20a%20server%20side%20component%20to%20either%20do%20ADAL%20on%20users%20behalf%2C%20or%20use%20app%20tokens%20if%20that%20works%20for%20your%20scenario.%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E
Highlighted
Valued Contributor

What is the best solution that currently shows how to get the Graph API bearer token from a SharePoint SPFX app?

 

ADAL.JS doesnt work in the modern Script Editor Web Part by @Mikael Svenson

 

I want to hopefully re-use my existing Javascript Graph API functions, i just need the best way to get the bearer token, and then muddle through working in my existing functions.

 

1 Reply
Highlighted
Solution
https://dev.office.com/sharepoint/docs/spfx/web-parts/guidance/call-microsoft-graph-from-your-web-pa... or if you can make due with access via Group. permissions, then use GraphHttpClient.

The other option is a server side component to either do ADAL on users behalf, or use app tokens if that works for your scenario.