I had to change my code in order to get a valid token that would allow me to access detailed profile info on an AAD user, using Graph API
However to my dismay eventually realised this token doesn't then allow access to my API which is also hosted on Azure behind AAD?
Is there a method which allows both?
NOTE The problem is with the Resource I pass in the header - it's either for my API, or for Graph, but I surely can't ask the user to log in twice?
What's the solution, other then embedding client secret once Graph Token used to log in ..?
Code sample uses Microsoft.IdentityModel.Clients.ActiveDirectory
Example 1 - this returns a token that I can use for my API but not Graph
authContext = new AuthenticationContext(authority);
PlatformParameters p = new PlatformParameters(PromptBehavior.Auto, hwnd);
AuthenticationResult result = null;
result = await authContext.AcquireTokenAsync(todoListResourceId, clientId, redirectURI, p);
Resource = https://[mywebsite].azurewebsites.net/api/Timekeeper
Example 2 - this gives me a token I can use for GraphAPI, but NOT my AAD API
Resource = https://graph.windows.net/