You don't have permission to perform this operation

I’m switching from using a 3rd party graphql request module to the one built into context.

It works fine locally, but when my custom function is triggered by a webhook I get the error: “You don’t have permission to perform this operation”

I added an authorization token to my request with permissions for everything (same token I used for the old request module that worked fine)

It’s added like so:

await ctx.api.gqlRequest(SUBSCRIPTION_UPDATE, {
        subscription: newSubscription,
        customerID,
        type: 'paused'
      }, { authorization: process.env.INTERNAL_API_TOKEN });

I have tripple checked and the process.env.INTERNAL_API_TOKEN does exist, I can console log it just fine in production and it’s correct.

I’m struggling to figure out why I’m getting a permissions error on this.

I tried changing it to { authorization:Bearer ${process.env.INTERNAL_API_TOKEN}}) with no luck.

1 Like

Tried creating a new role with full permissions to everything, and a new API token for that role.

But it’s still getting the same permissions error :frowning:

@sebastian.scholl any idea what’s going on. This is now a production issue for me, as I can’t revert to the previous one due to this other unrelated issue: Graphql-request - Cannot find name 'RequestInit'

@ilya.8base :pray:would really appreciate some help on this one. Still a production issue, my. webhook has already missed +100 events :cry:

Could you wrap the object ‘{ authorization: token }’ into ‘{ headers: { authorization: token } }’ and try one more time?

2 Likes

@eugene.antonevich Thank you so much!

That solved it for me!!!

1 Like