Following instructions in: https://docs.8base.com/docs/8base-console/custom-functions
await ctx.api.gqlRequest(QUERY, VARIABLES, {
headers: {
Authorization: "Bearer <MY_API_TOKEN>"
}
});
I have this example of a webhook for testing purposes:
import gql from 'graphql-tag';
module.exports = async (event, ctx) => {
console.log("EVENT:", event);
console.log("CTX:", ctx);
const query = gql`
query{
user{
id
email
}
}
`;
const token = "Bearer eyJhbGciOiJSUzI1NiIsInR5<TRIMMED>"
const API_TOKEN = "Bearer 4969008e<TRIMMED>"
const response = await ctx.api.gqlRequest(query, {
headers: {
Authorization: token
}
});
console.log(response);
};
The first one is a token from the frontend user, the second one is a token generated in the 8base console. Both raise: You don't have permission to perform this operation
when accessing the API.
Is there another way to accessing the API from a webhook, or is this the way and I’m just missing something.
Similar Question: Validate user in webhook