我正在尝试获取使用指定的客户Id注册的铬设备列表。
我已经完成了以下步骤。
令牌已成功创建。
{"access_token":"ya29.c.KpEB****K*********lufaGlx5k********hvAdADxBhOA****8R3rnTPKKnVb97sdPFG66wHy4FPrnx6KskafKXrBBfEgILdDelP-n5irpKm5h8y8oBWHO*******Xg","token_type":"Bearer","expiry_date":1587150649000,"refresh_token":"jwt-placeholder"}
现在,我正在尝试使用这个Bearer来访问以下API
https://www.googleapis.com/admin/directory/v1/customer/ourcustomerid/devices/chromeos
这总是给出以下错误。
{
"error": {
"errors": [{
"domain": "global",
"reason": "forbidden",
"message": "Not Authorized to access this resource/api"
}],
"code": 403,
"message": "Not Authorized to access this resource/api"
}
}不知道是什么问题。
发布于 2020-04-17 21:04:51
它在添加模拟用户电子邮件地址之后工作..。最初是
const jwtAuth = new google.auth.JWT(
quickstart.client_email,
null,
quickstart.private_key,
[
'https://www.googleapis.com/auth/admin.directory.device.chromeos',
'https://www.googleapis.com/auth/admin.directory.device.chromeos.readonly'
]
);然后,我增加了主题作为模拟用户电子邮件地址。
const jwtAuth = new google.auth.JWT(
quickstart.client_email,
null,
quickstart.private_key,
[
'https://www.googleapis.com/auth/admin.directory.device.chromeos',
'https://www.googleapis.com/auth/admin.directory.device.chromeos.readonly'
],
'email address of the impersonated user',
);https://stackoverflow.com/questions/61279055
复制相似问题