App Registration - The remote server returned an error: (401) Unauthorized

Rameez Ali 61 Reputation points
2022-03-12T19:52:14.317+00:00

I have registered an app in Azure and using the service principal to authenticate to the app, and get a listing of all Azure AD groups.

The permissions granted to the app are as follow:

182487-image.png
And the PowerShell code is as follow:

182486-image.png
I have tried almost everything but it is still giving me an error message saying that "The remote server returned an error: (401) Unauthorized."

Can someone please help me understand what I am doing wrong here?

Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} votes

Accepted answer
  1. Rahul Therayil 86 Reputation points
    2022-03-13T04:09:18.527+00:00

    Hi @Rameez Ali

    I see that you are using ClientID&Secret which is a system to system call instead on sign-on user context. Can you please try following Graph permissions and share the result?

    Permissions "Group.Read.All"
    Type "Application"

    You can also replace other permissions TYPE as "Application" instead of delegated. Following article outlines different about API types:

    https://learn.microsoft.com/en-us/graph/permissions-reference#group-permissions

    https://learn.microsoft.com/en-us/graph/api/group-list?view=graph-rest-1.0&tabs=http#permissions

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.