Skip to content

Commit

Permalink
Updated error message for Gmail Pub/Sub failures
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Feb 12, 2025
1 parent c32edf8 commit 5c8d855
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions lib/oauth2-apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -863,12 +863,22 @@ class OAuth2AppsHandler {
switch (err?.oauthRequest?.response?.error?.code) {
case 403:
// no permissions
this.setMeta(appData.id, {
authFlag: {
message:
'Service client does not have permissions to view Pub/Sub topics. Make sure the role for the service user is "Pub/Sub Admin".'
}
});
if (/Cloud Pub\/Sub API has not been used in project/.test(err?.oauthRequest?.response?.error?.message)) {
this.setMeta(appData.id, {
authFlag: {
message:
'Enable the Cloud Pub/Sub API for your project before using the service client. Check the server response below for details.',
description: err?.oauthRequest?.response?.error?.message
}
});
} else {
this.setMeta(appData.id, {
authFlag: {
message: 'Service client does not have permission to manage Pub/Sub topics. Grant the service user the "Pub/Sub Admin" role.'
}
});
}

throw err;
case 404: {
// does not exist
Expand Down Expand Up @@ -898,7 +908,7 @@ class OAuth2AppsHandler {
this.setMeta(appData.id, {
authFlag: {
message:
'Service client does not have permissions to modify Pub/Sub topics. Make sure the role for the service user is "Pub/Sub Admin".'
'Service client does not have permission to manage Pub/Sub topics. Grant the service user the "Pub/Sub Admin" role.'
}
});
throw err;
Expand Down Expand Up @@ -932,8 +942,7 @@ class OAuth2AppsHandler {
// no permissions
this.setMeta(appData.id, {
authFlag: {
message:
'Service client does not have permissions to view Pub/Sub subscriptions. Make sure the role for the service user is "Pub/Sub Admin".'
message: 'Service client does not have permission to view Pub/Sub topics. Grant the service user the "Pub/Sub Admin" role.'
}
});
throw err;
Expand Down Expand Up @@ -977,7 +986,7 @@ class OAuth2AppsHandler {
this.setMeta(appData.id, {
authFlag: {
message:
'Service client does not have permissions to modify Pub/Sub subscriptions. Make sure the role for the service user is "Pub/Sub Admin".'
'Service client does not have permission to manage Pub/Sub topics. Grant the service user the "Pub/Sub Admin" role.'
}
});
throw err;
Expand Down Expand Up @@ -1021,8 +1030,7 @@ class OAuth2AppsHandler {
// no permissions
this.setMeta(appData.id, {
authFlag: {
message:
'Service client does not have permissions to modify Pub/Sub policies. Make sure the role for the service user is "Pub/Sub Admin".'
message: 'Service client does not have permission to view Pub/Sub topics. Grant the service user the "Pub/Sub Admin" role.'
}
});
throw err;
Expand Down Expand Up @@ -1065,8 +1073,7 @@ class OAuth2AppsHandler {
// no permissions
this.setMeta(appData.id, {
authFlag: {
message:
'Service client does not have permissions to modify Pub/Sub policies. Make sure the role for the service user is "Pub/Sub Admin".'
message: 'Service client does not have permission to manage Pub/Sub topics. Grant the service user the "Pub/Sub Admin" role.'
}
});
throw err;
Expand Down

0 comments on commit 5c8d855

Please sign in to comment.