I'm building a simple demo application netcoreapp6.0 where I offer a sign-in button to log in users against Azure AD.
For the initial login we request basic claims like 'user.read'.
Now we need to acquire additional claims from our users as soon as the open specific pages on the website.
I can't get around how to acquire these claims after the user already authenticated.
Microsoft has consent buttons on https://developer.microsoft.com/en-us/graph/graph-explorer which do exactly what I need. However, I can't find any documentation on the /common/reprocess/ endpoint they are using.
What we've tried so far:
Adding claims policies:
services.AddAuthorization(options => {
options.AddPolicy("ClaimsTest", policy => policy.RequireClaim("Contacts.Read"));
options.AddPolicy("MustHaveOneDrive", policy => policy.RequireClaim("Files.ReadWrite"));
});
And then checking those claims like:
[Authorize(Policy="MustHaveOneDrive")]
This works. If the user does not provide the claims, access is denied. I now want to have the app to ask the user for the required claims just like Microsoft does in thei graph explorer.
I can't provide code for this as we have no idea where to start.