MCPcopy Create free account
hub / github.com/openclaw/gogcli / wrapAdminDirectoryErrorWithScopes

Function wrapAdminDirectoryErrorWithScopes

internal/cmd/admin_common.go:115–134  ·  view source on GitHub ↗
(err error, account, scopes string)

Source from the content-addressed store, hash-verified

113}
114
115func wrapAdminDirectoryErrorWithScopes(err error, account, scopes string) error {
116 errStr := err.Error()
117 if strings.Contains(errStr, "accessNotConfigured") ||
118 strings.Contains(errStr, "Admin SDK API has not been used") {
119 return errfmt.NewUserFacingError("Admin SDK API is not enabled; enable it at: https://console.developers.google.com/apis/api/admin.googleapis.com/overview", err)
120 }
121 if strings.Contains(errStr, "insufficientPermissions") ||
122 strings.Contains(errStr, "insufficient authentication scopes") ||
123 strings.Contains(errStr, "Not Authorized") {
124 return errfmt.NewUserFacingError("Insufficient permissions for Admin SDK API; ensure your service account has domain-wide delegation enabled with "+scopes, err)
125 }
126 if strings.Contains(errStr, "domain_wide_delegation") ||
127 strings.Contains(errStr, "invalid_grant") {
128 return errfmt.NewUserFacingError("Domain-wide delegation not configured or invalid; ensure your service account has domain-wide delegation enabled in Google Workspace Admin Console", err)
129 }
130 if isConsumerAccount(account) {
131 return errfmt.NewUserFacingError("Admin SDK Directory API requires a Google Workspace account with domain-wide delegation; consumer accounts (gmail.com/googlemail.com) are not supported.", err)
132 }
133 return err
134}

Callers 2

wrapAdminDirectoryErrorFunction · 0.85

Calls 3

NewUserFacingErrorFunction · 0.92
isConsumerAccountFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected