mattermost-community / mattermost-app-servicenow

Service Now app for Mattermost
Apache License 2.0
4 stars 5 forks source link

Configuring Service Now oAuth sometimes fails with an error about autherization #42

Open DHaussermann opened 2 years ago

DHaussermann commented 2 years ago

Once I have service now installed, when I try to configure the oAuth, I see an error suggesting I do not have permission top store the data.
This issue is intermittent when testing on multiple servers image

Steps:

Observed: Authorization error and credentials did not save

hanzei commented 2 years ago

FYI: This error is thrown when an authenticated request is made to an API endpoint of the apps plugin: https://github.com/mattermost/mattermost-plugin-apps/blob/2f6900c918e02a01d19bc0c03671c8229109240b/server/httpin/handler.go#L127-L131

mickmister commented 2 years ago

@hanzei I was on a call with @DHaussermann when this error happened. His ServiceNow App was running through ngrok, so we were able to inspect the request/response. The call request to the ServiceNow App indeed contained the acting_user_access_token in the provided context, and we are creating an client via appclient.AsActingUser(creq.Context) here just before this error is returned from the App.

Since the Apps plugin determined that the Mattermost-User-Id header is blank, I assume this has something to do with the access token being rejected by the MM server. I'm not sure what factors could cause this to happen though.