Azure Ad Application Permission - azure

In azure ad application, We are giving permission to application and run our app. It give proper data, after doing this we remove all permission, then also we does not get unauthorized error. What is issue with Azure Ad permission? Is there cache issue, which we have to clear?

I don't know how you revoked the permission for your application but I assume you used the Azure Portal. The most likely reason is that you forgot to hit the Grant permissions button:

To revoke a permission isn’t currently available through the Portal. When you apply a permission a link is created between the application and service principal.
There are two types of permission grants between Applications and Service Principals.
Application grants are represented by AppRoleAssignments. These can be seen by using the graph api to get them for a particular Service Principal. Once you know the principal id for the permission you want to delete you can remove it using by sending a delete request to the delete endpoint. .
Delegated permission are represented by OAuth2PermissionGrants. Similar to AppRoleAsssignments there is a get method and a delete method.
Let me know if I need to make anything clearer or can help.

Related

What permission do I need on Azure AD application to read a folder in ShraePoint?

I have an app registered in Azure AD with the following approved permissions:
Microsoft Graph: Files.ReadWrite.All, Sites.ReadWrite.All, Sites.Selected, User.Read
and
SharePoint: Sites.ReadWrite.All, Sites.Selected
Yet a request to load a folder at / fails with 403 Forbidden (the same C# application that uses a different, registered earlier, Azure AD application works fine - I just can't figure out what the differences are, and how to get second app's permissions to work like the first app does).
Which permissions do I need to read a folder?
Are there logs that can give me more information?
This depends on which authentication flow you use, because you are only granting application permissions, which are only supported in the client credentials flow. So if you're using the client credentials flow, your permissions are sufficient. However, if you are using auth code flow or ROPC flow, you also need to grant Files.ReadWrite.All and Sites.ReadWrite.All delegated permissions.
It turned out, I needed Sites.Selected permission (which I did). However, I had to use the PowerShell PnP module to explicitly grant write permission to my app for each site I need to access. From what I figured out as of today there is no GUI way to do that configuration (I suspect sites could have been configured when the application's permission request was initially granted, but I am not the one who approved those requests).

Why I am able to access the users of a different tenant without adding any API permission to application in Azure Portal?

I created an application named MyApp in my Tenant A with multitenant access. Also, I didn't add any API permissions to it in Azure Portal. I also removed default User.Read permission.
After that, I implement a backend project with using msal4j library. In backend code, I sent harcoded scope Directory.ReadWrite.All.
After that, I run the backend project. The project showed Microsoft sign in pop up in the browser. I provided the credentials of admin of another tenant named B(Tenant B have 16 users). After the successful sign in, the Permission Requested pop-up showed, It was written a description about the Directory.ReadWrite.All. This was normal since I was add Directory.ReadWrite.All as a scope in my backend code.
After approving that requested permission as an admin of Tenant B. I can list the 16 users of the Tenant B with GET /users endpoint of the Microsoft Graph API. So, the MyApp which was created in Tenant A could access the users of Tenant B.
However, how it was possible? Because I didn't add any API permission to my MyApp in the Azure Portal. You can see above screnshot that is empty. I expected to get an error like "Insufficient privilege" when accessing the GET /users endpoint. But I didn't. I can successfully access the all 16 users although I didn't add the Directory.ReadWrite.All API permission in the Azure Portal into MyApp.
If sending Directory.ReadWrite.All as scope from backend project is enough to access to GET /users endpoint. Why we want to use API permissions in the Azure Portal?
The Azure portal permissions are what we call static permissions.
You use them with the ".default" special scope, e.g. https://graph.microsoft.com/.default.
When you specify a scope in the authentication request, that is a dynamic permission.
It is a feature of the newer v2 endpoint that allows you to request the needed permissions at runtime instead of ahead of time.
It's pretty nice for multi-tenant apps since updating permissions can be done more easily, and you can implement optional features better (that require additional permissions).
Docs: https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent and https://learn.microsoft.com/en-us/azure/active-directory/develop/consent-framework

How do I add administrator accounts for granting static permissions to my Azure AD App?

I have set up a Azure Active Directory App so that I can access the Microsoft Graph API with MSAL. However, I want to perform API calls without a user (https://learn.microsoft.com/en-us/graph/auth-v2-service) and as such I have added a few permissions that require "Admin consent" to my app. However, I cannot find a way to grant my app these permissions.
I've tried looking around the Azure portal for a way to grant these permissions but without success. I have also tried using the https://login.microsoftonline.com/{tenant}/adminconsent&... link to grant permissions, but unsucessfully so.
The response I received was
AADSTS500201: We are unable to issue tokens from this API version for
a Microsoft account. Please contact the application vendor as they
need to use version 2.0 of the protocol to support this.
I do not have an Azure subscription (not even the free one), but seeing as I was able to add apps to Azure AD as well as get access tokens and then make API calls on behalf of the authorized users I assumed I might not need a subscription.
I just made another app and now I have the grant consent button when I open the API Permissions view.

[Azure AD]: Delete User Group Unauthorized

I was Integration Azure Ad in my application User and Group i was maintain in local that the same scenario i was made in azure using Graph API.
The Create user, create Group, Add the member into Group and remove the member in group also working fine for me. but, the Remove group is not working. it's throw 403 forbidden.
The Sample Post Request is screen is
I was Selected all Application permission.in Microsoft Graph and Active Directory. and Grant Permissions.but, i also Get the Insufficient privileges to complete the operation.
My Access token is
eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IkhIQnlLVS0wRHFBcU1aaDZaRlBkMlZXYU90ZyIsImtpZCI6IkhIQnlLVS0wRHFBcU1aaDZaRlBkMlZXYU90ZyJ9.eyJhdWQiOiJodHRwczovL2dyYXBoLndpbmRvd3MubmV0LyIsImlzcyI6Imh0dHBzOi8vc3RzLndpbmRvd3MubmV0LzFlNDVmNzc1LTlhMTAtNDQ1MS04YmI2LTRjNTVkMDgxMDI1Ni8iLCJpYXQiOjE1MDczNzUyNzQsIm5iZiI6MTUwNzM3NTI3NCwiZXhwIjoxNTA3Mzc5MTc0LCJhaW8iOiJZMlZnWU5qNjBKcEZwWkxyNTZFTm9WK2NGejZRQWdBPSIsImFwcGlkIjoiMGJhZTJjMTktMzEwNC00YWM3LTkzNjQtMGQ2NjI1YmU5NDc0IiwiYXBwaWRhY3IiOiIxIiwiaWRwIjoiaHR0cHM6Ly9zdHMud2luZG93cy5uZXQvMWU0NWY3NzUtOWExMC00NDUxLThiYjYtNGM1NWQwODEwMjU2LyIsIm9pZCI6ImU5OGRjYTkzLTI2MzktNDU0ZC1hMDg3LWNkZjIzNjg2ODhlMCIsInJvbGVzIjpbIkRldmljZS5SZWFkV3JpdGUuQWxsIiwiRGlyZWN0b3J5LlJlYWQuQWxsIiwiTWVtYmVyLlJlYWQuSGlkZGVuIiwiRGlyZWN0b3J5LlJlYWRXcml0ZS5BbGwiLCJEb21haW4uUmVhZFdyaXRlLkFsbCIsIkFwcGxpY2F0aW9uLlJlYWRXcml0ZS5Pd25lZEJ5IiwiQXBwbGljYXRpb24uUmVhZFdyaXRlLkFsbCJdLCJzdWIiOiJlOThkY2E5My0yNjM5LTQ1NGQtYTA4Ny1jZGYyMzY4Njg4ZTAiLCJ0ZW5hbnRfcmVnaW9uX3Njb3BlIjoiQVMiLCJ0aWQiOiIxZTQ1Zjc3NS05YTEwLTQ0NTEtOGJiNi00YzU1ZDA4MTAyNTYiLCJ1dGkiOiJMVHBWY3VxUFBFMm1uQ1FaYTBrSUFBIiwidmVyIjoiMS4wIn0.liMUK4oOBtNuU-AFHr0VfwFxiIV57pMdha8oae2Xu7tKgQR8HeSTdKm7Ex4s7n7GSAF-2YATXMdFGF5vvfrlF3ALMH8zvENJwY8BOrVsB516z_BROVmagvAKuPWoByRrlDPrhsalJBwwcy_ex1bG-sWvGSBoMpKy53EGWzMt9IF9CSp5IiiVp5xHXHog8BV-P-Bb98smOrnrTK7WhO0ZMkDIUCbfF-4QySwAbFJaUSZPqdZXA8XE-rt7RLZGlpbSpAv5Lmzb2V4mAioO1eSKEjoYQApifCyNHg76FgcRx10PPt1HO2yN9z6s7RaH6H1C1BABJRPaO58SCJI-BsgjFg
Anyone Know Help me.
Thanks in Advance.
Deleting directory objects isn't support at this time using application credentials.
This applies to both the Azure AD Graph and the Microsoft Graph.
The only way to delete objects is using user delegated auth with a token from a user that has sufficient permissions to do so (generally an admin).
PS: I can tell you are using application credentials and application permission because the token you shared, when put in jwt.ms has an appId and roles.

AADSTS90093:Calling principal cannot consent due to lack of permissions in Azure Active directory

We have a requirement to integrate the Web application to Azure active directory Multi-tenant authentication. We have changed the end point URL to "https://login.microsoftonline.com/common". We tried to login to our application with our work email id. We got the following Error.
Additional technical information:
Correlation ID: 72ec287c-XXXX-XXXX-XXXX-4bf49d167541
Timestamp: 2017-04-07 09:48:57Z
AADSTS90093: Calling principal cannot consent due to lack of permissions.
We have find that we missed some permissions to our Application in AD.Could anyone please help us what kind of permissions need to provide.
Thanks in advance.
The error is saying that the user who is logging in cannot give consent for the app. When you log in from a tenant where the app is not yet consented, you must be an AAD admin.
This error indicates that the users are not able to give the consent to the app.
There are two permission level in Azure AD developing, one requires administrator's consent and the other doesn't.
If the app you were using was developed by your organization, you also can grant the permission via the Azure portal when it is register like figure below:
If the app was developed by other organization, please ensure the app also provide a way(maybe a separate button) to grant the consent for the organization. Then you can notify the administrator to grant the permission for all organization. More detail about the admin consent, you can refer this document.

Resources