我正在尝试通过GApi AngularJS库在GMail帐户上创建转发设置。我能够使用相同的GApi功能创建标签和列表转发地址,但不能创建新的转发电子邮件地址。我也关注此documentation并尝试使用试用!部分,但没有成功。
我正在尝试这样做,如下面的代码:
GAuth.login().then(function(obj){
GApi.executeAuth('gmail', 'users.settings.forwardingAddresses.create', {'userId': obj.id, 'forwardingAddress': 'email@mail.com.br'}).then( function(resp) {
console.log(resp);
}, function() {
console.log("error :(");
});
});
我还使用API SCOPES 进行了一些配置,使用相同的库进行授权:
app
.constant('GoogleClientId', '{YOUR_GOOGLECLIENT_ID}')
.constant('GoogleScopes', [
'https://mail.google.com/',
'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/gmail.settings.sharing'
])
.run([
'GApi',
'GAuth',
'GoogleClientId',
'GoogleScopes',
function(GApi, GAuth, GoogleClientId, GoogleScopes) {
GApi.load('gmail', 'v1');
GAuth.setClient(GoogleClientId);
GAuth.setScope(GoogleScopes.join(' '));
}
]);
然后我从API获得了这条消息:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "forbidden",
"message": "Access restricted to service accounts that have been delegated domain-wide authority"
}
],
"code": 403,
"message": "Access restricted to service accounts that have been delegated domain-wide authority"
}
我错过了什么吗?