Can Apps Script list forwarding addresses for individual users without listing each in the urlFetchWhitelist

9 views
Skip to first unread message

Dustin Christlieb

unread,
Jul 1, 2024, 4:31:17 PM (11 hours ago) Jul 1
to Google Apps Script Community

I am trying to list forwarding addresses configured by users in Google Workspace. The code seems to work, but I'm receiving errors about the request failing because the URL has not been whitelisted in the script manifest. I am a Super Admin, using a service account, I have enabled the Gmail API on my project and in the Apps Script service. I have set up domain wide delegation, but I cannot list the unique URL for each user in the script manifest and using urlFetchWhitelist addresses (because once the app is completed, admins would run this on their own environment and the userlist is unknown until the script is run.)

"https://gmail.googleapis.com/gmail/v1/users/*", "https://gmail.googleapis.com/gmail/v1/users/*/settings/forwardingAddresses", "https://gmail.googleapis.com/gmail/v1/users/test...@example.com/settings/forwardingAddresses",

Each user with the exception of test...@example.com listed in the urlFetchWhitelist example above gets an error: Error fetching settings for test...@example.com: Exception: Request to https://gmail.googleapis.com/gmail/v1/users/test...@example.com/settings/forwardingAddresses failed because the URL has not been whitelisted in the script manifest. (Response: Empty)

I have tried listing individual user addresses in the URLwhitelist in the script manifest which does not return an error. I'm expecting to be able to make the API calls to list if a user has forwarding enabled and if so, list the forwarding addresses for each user who has configured it in Gmail settings.

Reply all
Reply to author
Forward
0 new messages