アプリに OAuth ログインがあります。その後、私はaccess_tokenを持っています。
Google トークン情報サービスでトークンを確認します。
https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=<access_token>
そしてそれは戻ります:
{
"issued_to": "554651647288-tquejcu6mctplq4kin5dd9r81mtkg3vv.apps.googleusercontent.com",
"audience": "554651647288-tquejcu6mctplq4kin5dd9r81mtkg3vv.apps.googleusercontent.com",
"scope": "https://www.googleapis.com/auth/admin.directory.group https://www.googleapis.com/auth/admin.directory.orgunit https://www.googleapis.com/auth/admin.directory.user",
"expires_in": 3299,
"access_type": "online"
}
ご覧のとおり、管理者ユーザー ディレクトリのアクセス許可があります。
次に、ユーザーに関する情報を取得するための GET リクエストを送信します
curl -X GET https://www.googleapis.com/admin/directory/v1/users/test_user@test.com?access_token=<access_token>
そして、グーグルは私に正しいユーザー情報を返しました。その後、ユーザーのリストを取得することにしました。
curl -X GET https://www.googleapis.com/admin/directory/v1/users?customer=my_customer&access_token=<access_token>
そしてグーグルは私を返しました:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
しかし、なぜグーグルが私にエラーを返したのか理解できません。
この問題について教えてください。
ありがとう。