3

We have a lightning web component, that updates via the EMP API from an 'after insert' apex trigger. During testing we found that if we log in as a non-admin user (custom profile), the onError function from the 'lightning/empApi' gets called with the following response:

{
channel: "/meta/subscribe",
clientId: "<id>",
error: "403:denied_by_security_policy:create_denied",
id: "264",
subscription: "event/<my_event>",
successful: false
}

The custom profile has Read and Create permission for the <my_event> event, has API enabled and Read, Write, Create and Edit permissions for the Push Topic.

(PS. The subscribe function resolves and returns with replayId: -1)

Any ideas ?

3
  • Are you sure you granted permissions on the event object? The available permissions are Read and Create, there's no Write. You need to grant Create.
    – identigral
    Aug 6 '20 at 18:16
  • Yes, sorry - I meant Read and Create Aug 6 '20 at 20:09
  • Everything works as expected when signed in as an admin - doesn't that mean, the way we create runtime context is correct, and that the issue lies in the permissions (or something else) ? Aug 6 '20 at 20:30
4

We figured it out. We needed to change the Deployment Status of the Platform Event from In Development to Deployed. As the docs say:

Deployment status lets you control who can access objects or platform events. We recommend that you select In Development while you set up your app or customization. That way, only admins (or users with the Customize Application permission) can access the object or platform event.

When you’re ready to grant users access, change the status to Deployed.

Later, if you change the object or platform event, select In Development again. Keep in mind that for custom or external objects, users can’t see custom tabs, related lists, or reports while objects are in development.

That is why it worked when signed in as an Admin, but not as a user with our Custom Profile

2
  • I am seeing the same error in my Aura Components. Permission Set grants Read/Create and the Platform Event is deployed. Sep 21 '20 at 9:44
  • I dont have a lot of experience in aura, so I can’t tell you anymore that what I wrote in the answer Sep 21 '20 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.