I figured out that there are multiple ways, an admin can consent permissions requested by an app:
Option 1: With the authorization endpoint and a parameter "prompt=consent" like this:
https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/authorize?client_id={client-id}&prompt=consent&response_type=code+id_token&redirect_uri=https://localhost&scope=https://graph.microsoft.com/.default
Microsofts quote for this is the following:
However, there is also a dedicated admin consent endpoint you can use if you would like to proactively request that an administrator grants permission on behalf of the entire tenant. Using this endpoint is also necessary for requesting Application Permissions (which can't be requested using the authorize endpoint).
Strange is now, that if I am calling this endpoint with an admin user, I can consent to the app, even to all application permissions. This is strange to me, because I thought that the admin consent endpoint is for this.
I also get a token now that contains scopes of some of my application permissions.
Now I call this endpoint:
https://login.microsoftonline.com/{tenantId}/adminConsent?client_id={client-id}&redirect_uri=https://portal.azure.com/TokenAuthorize
This works as expected and I get also the admin consent, but no token.
Also it seems that here is no difference between endpoint v1 and endpoint v2. So the adminconsent endpoint seems to be version agnostic.
My questions are now:
If I only want to request admin consent without getting any access token, I will use the admin consent endpoint, right?
Is the admin consent endpoint independent of v1 or v2 endpoints?
But most important: I use the authorize endpoint only to get tokens on behalf of users. But if I access this endpoint with promt=consent parameter as an admin, why does this endpoint also returns a token with some of the application (not delegated) permissions?
(For example I added the application permission "Application.Read.All" what was returned in the token. Another application permission "AccessReview.Read.All" was not included in the token. This does not look like a straightforward implementation to me...