authorization error sometimes and gateway authentication failed for microsoft authroization

Kumar Chary, Naveen
116
Reputation points
Hello, this is about activating the eligible role using the ARM API.
- 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.
- 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)
- the custom role is assigned to entraid group in pim as eligible on subscription level, users will be added to the group.
- the step 2, though the role is assigned on sub level, using inheritance the role is activated on resource level.
- 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
Sign in to answer