I have created a saleor app cloning the saleor-app-template
I have configured the manifest like this:
export default createManifestHandler({
async manifestFactory(context) {
const manifest: AppManifest = {
name: packageJson.name,
tokenTargetUrl: `${context.appBaseUrl}/api/register`,
appUrl: context.appBaseUrl,
permissions: ['MANAGE_USERS', 'MANAGE_ORDERS'],
id: "saleor.app",
version: packageJson.version,
webhooks: [customerCreatedWebhook.getWebhookManifest(context.appBaseUrl)],
extensions: [
{
label: 'Messages',
mount: 'NAVIGATION_CUSTOMERS',
target: 'APP_PAGE',
permissions: ['MANAGE_USERS', 'MANAGE_ORDERS'],
url: '/'
}
],
};
return manifest;
},
});
And I have created an async webhook
export const customerCreatedWebhook = new SaleorAsyncWebhook<any>({
name: 'Customer created',
webhookPath: 'api/webhooks/customerCreated',
asyncEvent: 'CUSTOMER_CREATED',
isActive: true,
apl: saleorApp.apl,
subscriptionQueryAst: customerCreatedSubscription,
onError(error: WebhookError | Error) {
console.error(error);
},
async formatErrorResponse(
error: WebhookError | Error,
req: NextApiRequest,
res: NextApiResponse
) {
return {
code: 400,
body: "My custom response",
};
},
});
const handler : NextWebhookApiHandler<any> = async (req, res, context) => {
const { payload, authData } = context;
const { saleorApiUrl, token, appId } = authData;
console.log(payload.user?.email);
console.debug(payload.user?.email);
return res.status(200).end();
}
export default customerCreatedWebhook.createHandler(handler)
I'm running this app on localhost:3000 and I'm using ngrok for exposing this port and use the public URL on the saleor dashboard, besides that, my saleor dashboard is running on localhost:9000, The Saleor API and Database are running on docker, and I configured my APL with upstash
APL configuration
I have these variables on the .env file for the app:
UPSTASH_URL=[url]
UPSTASH_TOKEN=[token]
APL=upstash
But then when I go to the saleor dashboard -> apps and try to install the external app, I get this error Registration failed: could not save the auth data.
I don't know what is missing or what I'm doing wrong
I also used the default APL configuration and the file .saleor-app-auth.json was created with these values
{"domain":"localhost:8000","token":"L8XSXDGjfOPJ5QyyUgpXWA05bvChpx","saleorApiUrl":"http://localhost:8000/graphql/","appId":"QXBwOjI1","jwks":"{\"keys\": [{\"kty\": \"RSA\", \"key_ops\": [\"verify\"], \"n\": \"xk51hxPXE4v7ERaBpoZBRU-NK_nKrK-lD-mOevJX_jigZyqGSRIGrald5K2f_YHMXVNzbuXHSO0JJWC-sjYuBCvmioKj5vr7cmTqUkLLIJl4pOXRGsGuj9YxTVeXnCBYKc2i60NAADlinN3oR1k1zhlne1cDuj6GBUxu31yCR88KLR1NIFreHLTzYjBp6IZSrGorS1_7OFT9QsKaroHWODCrV5PFAIosoaoTt16i677ZAylnQOJcfND-Vx5LH8qwavD8PIo3IzWZvOVQWRarDS4cLXbXPM4yNhDx1AFpm1UIyKP6ajIXp3v30SO3vzhtnU8earZMbOXSVOARtBwcTw\", \"e\": \"AQAB\", \"use\": \"sig\", \"kid\": \"1\"}]}"}
The app was installed correctly on the saleor dashboard, but then when I created a customer, the webhook throw SIGNATURE_VERIFICATION_FAILED
signature verification failed