RuiRomano / pbimonitor

MIT License
207 stars 76 forks source link

GraphTimer Error 403 Forbidden #11

Closed aalabed-pro-et closed 1 year ago

aalabed-pro-et commented 2 years ago

Hello, It AuditTimer and CatagTimer are working fine for me but i am getting Error 403 Forbidden when i run Graphtimer, any idea ?

2021-12-23T10:34:48.607 [Information] INFORMATION: Ellapsed: 0.2177514s 2021-12-23T10:34:48.922 [Information] OUTPUT: 2021-12-23T10:34:48.923 [Information] OUTPUT: 2021-12-23T10:34:48.923 [Information] OUTPUT: HistoryId: 1 2021-12-23T10:34:48.923 [Information] OUTPUT: 2021-12-23T10:34:48.923 [Information] OUTPUT: Message : Response status code does not indicate success: 403 (Forbidden). 2021-12-23T10:34:48.923 [Information] OUTPUT: StackTrace : at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord) 2021-12-23T10:34:48.924 [Information] OUTPUT: Exception : Microsoft.PowerShell.Commands.HttpResponseException 2021-12-23T10:34:48.924 [Information] OUTPUT: InvocationInfo : {Invoke-RestMethod} 2021-12-23T10:34:48.924 [Information] OUTPUT: Line : $result = Invoke-RestMethod -Method Get -Uri $url -Headers $headers 2021-12-23T10:34:48.924 [Information] OUTPUT: 2021-12-23T10:34:48.924 [Information] OUTPUT: Position : At C:\home\site\wwwroot\Scripts\Fetch - Graph.ps1:61 char:19 2021-12-23T10:34:48.924 [Information] OUTPUT: + … $result = Invoke-RestMethod -Method Get -Uri $url -Headers $headers … 2021-12-23T10:34:48.924 [Information] OUTPUT: + ~~~~~~~~~~~~~ 2021-12-23T10:34:48.924 [Information] OUTPUT: HistoryId : 1 2021-12-23T10:34:48.924 [Information] OUTPUT: 2021-12-23T10:34:49.366 [Error] EXCEPTION: Response status code does not indicate success: 403 (Forbidden).Exception :Type : Microsoft.PowerShell.Commands.HttpResponseExceptionResponse : StatusCode: 403, ReasonPhrase: 'Forbidden', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:{Date: Thu, 23 Dec 2021 10:34:48 GMTCache-Control: no-cacheTransfer-Encoding: chunkedStrict-Transport-Security: max-age=31536000request-id: 7731876f-d05c-474c-b082-57a7efdd63f3client-request-id: 7731876f-d05c-474c-b082-57a7efdd63f3x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"North Europe","Slice":"E","Ring":"4","ScaleUnit":"005","RoleInstance":"DU6PEPF00001536"}}x-ms-resource-unit: 1Content-Type: application/json}TargetSite :Name : ThrowTerminatingErrorDeclaringType : System.Management.Automation.MshCommandRuntime, System.Management.Automation, Version=7.0.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType : MethodModule : System.Management.Automation.dllStackTrace :at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)Message : Response status code does not indicate success: 403 (Forbidden).Source : System.Management.AutomationHResult : -2146233088TargetObject : Method: GET, RequestUri: 'https://graph.microsoft.com/beta/users?$select=id,mail,companyName,displayName,assignedLicenses,onPremisesUserPrincipalName,UserPrincipalName,jobTitle,userType', Version: 1.1, Content: System.Net.Http.StringContent,

rehdenic commented 2 years ago

I am getting the same error.

Any new information?

RuiRomano commented 1 year ago

I had a typo on the docs, the permissions on graph should be: User.Read.All and Directory.Read.All

https://github.com/RuiRomano/pbimonitor#create-a-service-principal--security-group