api: server: check for unauthorized error Upstream-commit: 8c17d58eb8a90428078e9228864fa819ef8783f2 Component: engine