Reputation: 61
I was going through the api doc for setting forwarding address via gmail Apis https://developers.google.com/gmail/api/reference/rest/v1/users.settings.forwardingAddresses/create
I am getting the following error when trying to access this api.
{
"code" : 403,
"errors" : [ {
"domain" : "global",
"message" : "Access restricted to service accounts that have been delegated domain-wide authority",
"reason" : "forbidden"
} ],
"message" : "Access restricted to service accounts that have been delegated domain-wide authority",
"status" : "PERMISSION_DENIED"
}
If there is a way to access this api? Few other doubts I have:
Upvotes: 2
Views: 554
Reputation: 6481
At least for accounts outside a domain that you administrate
If I understand correctly, you wish to make an app that will ask for a users permission to allow your app to set up email forwarding for them via the API.
The listing in the docs for the scope: https://www.googleapis.com/auth/gmail.settings.sharing
which is required for that endpoint says:
Operations guarded by this scope are restricted to administrative use only. They are only available to Google Workspace customers using a service account with domain-wide delegation.
This is as much as security measure as anything. Which means that what you are trying to do is not possible, unless it was for members of your domain only.
It will not work for gmail accounts or other domains. You need to authorise it properly.
If you wanted to get it working for your domain, your first step needs to be getting a service account working, this is a good starting point.
References
Upvotes: 1