我正在尝试通过google api使用curl终端电话将新用户添加到我的Google Apps应用帐户域(link1 link2)。
我已经有了访问和刷新令牌,只需要弄清楚如何进行api调用。这是我一直在测试的:
//version 1
curl https://www.googleapis.com/admin/directory/v1/users \
-H "Authorization: Bearer {access_token_here}" \
-d '{"name":{"familyName":"pan","givenName":"peter"},"password":"asdf","primaryEmail":"asdf@dsf.com"}' \
-X POST
//version 2
curl https://www.googleapis.com/admin/directory/v1/users?fields=name%2Cpassword%2CprimaryEmail&key={api_key_for_browsers}
-H "Authorization: Bearer {access_token_here}" \
-d '{"name":{"familyName":"pan","givenName":"peter"},"password":"asdf","primaryEmail":"asdf@dsf.com"}' \
-X POST
但他们只是返回错误:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
即使访问密钥来自用户登录后提供的授权代码,也授予了对我的应用程序的访问权限。
我的问题: