Skip to content

Commit 9db36d3

Browse files
[service-utils] Improve 403 error messages with team and project details
1 parent 72cc27a commit 9db36d3

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.changeset/blue-mice-prove.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@thirdweb-dev/service-utils": patch
3+
---
4+
5+
Better error messages for 403 responses

packages/service-utils/src/core/authorize/service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function authorizeService(
1919
if (!team.enabledScopes.includes(serviceConfig.serviceScope)) {
2020
return {
2121
authorized: false,
22-
errorMessage: `Invalid request: Unauthorized service: ${serviceConfig.serviceScope}. You can view the restrictions for this team in your dashboard: https://thirdweb.com`,
22+
errorMessage: `Invalid request: Unauthorized service: ${serviceConfig.serviceScope} for team: ${team.name} (${team.id}). You can view the restrictions for this team in your dashboard: https://thirdweb.com`,
2323
errorCode: "SERVICE_UNAUTHORIZED",
2424
status: 403,
2525
};
@@ -42,7 +42,7 @@ export function authorizeService(
4242
if (!service) {
4343
return {
4444
authorized: false,
45-
errorMessage: `Invalid request: Unauthorized service: ${serviceConfig.serviceScope}. You can view the restrictions on this project in your dashboard: https://thirdweb.com`,
45+
errorMessage: `Invalid request: Unauthorized service: ${serviceConfig.serviceScope} for project: ${project.name} (${project.publishableKey}). You can view the restrictions on this project in your dashboard: https://thirdweb.com`,
4646
errorCode: "SERVICE_UNAUTHORIZED",
4747
status: 403,
4848
};
@@ -56,7 +56,7 @@ export function authorizeService(
5656
if (!isActionAllowed) {
5757
return {
5858
authorized: false,
59-
errorMessage: `Invalid request: Unauthorized action: ${serviceConfig.serviceScope} ${serviceConfig.serviceAction}. You can view the restrictions on this API key in your dashboard: https://thirdweb.com/create-api-key`,
59+
errorMessage: `Invalid request: Unauthorized action: ${serviceConfig.serviceScope} ${serviceConfig.serviceAction} for project: ${project.name} (${project.publishableKey}). You can view the restrictions on this API key in your dashboard: https://thirdweb.com/create-api-key`,
6060
errorCode: "SERVICE_ACTION_UNAUTHORIZED",
6161
status: 403,
6262
};

0 commit comments

Comments
 (0)