authorization error sometimes and gateway authentication failed for microsoft authroization

Kumar Chary, Naveen 116 Reputation points
2025-03-05T12:17:21.0966667+00:00

Hello, this is about activating the eligible role using the ARM API.

  1. Created a custom role (only with admin login action) no read action- coz we do not want user to see the machines in the portal.
  2. We have a ps script that can be used inside the virtual machine to activate the eligible role (admin- custom role) steps are connect-azaccount, retreive scope,sub create gid and invokes the rest api (reference- https://learn.microsoft.com/en-us/entra/id-governance/privileged-identity-management/pim-resource-roles-activate-your-roles#activate-a-role-with-azure-resource-manager-api)
  3. the custom role is assigned to entraid group in pim as eligible on subscription level, users will be added to the group.
  4. the step 2, though the role is assigned on sub level, using inheritance the role is activated on resource level.
  5. it was working great, however, from couple of weeks it's throwing errors. error1- "code":"GatewayAuthenticationFailed","message":"Gateway authentication failed for 'Microsoft.Authorization' error 2- The client '' with object id '' does not have the authorization to perform action 'Microsoft.Resources/subscriptions/resourceGroups/read' over scope 'x' or the scope is invalid. If access was recently granted, please refresh your credentials.'

Rest api used- PUT https://management.azure.com/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}?api-version=2020-10-01

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
23,523 questions
{count} votes

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.