php-samples icon indicating copy to clipboard operation
php-samples copied to clipboard

quickstart.php sample for gmail has bad scope

Open askew-etc opened this issue 3 years ago • 0 comments

Expected Behavior

Response from running php quickstart.php

Labels:
- CHAT
- SENT
- INBOX
- IMPORTANT
- TRASH
- DRAFT
- SPAM
- CATEGORY_FORUMS
- CATEGORY_UPDATES
- CATEGORY_PERSONAL
- CATEGORY_PROMOTIONS
- CATEGORY_SOCIAL
- STARRED
- UNREAD
- NWCR
- TechConnect
- Unwanted

Actual Behavior

Message: {                                                                                                                                                                                                     
  "error": {
    "code": 403,
    "message": "Request had insufficient authentication scopes.",
    "errors": [
      {
        "message": "Insufficient Permission",
        "domain": "global",
        "reason": "insufficientPermissions"
      }
    ],
    "status": "PERMISSION_DENIED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "ACCESS_TOKEN_SCOPE_INSUFFICIENT",
        "domain": "googleapis.com",
        "metadata": {
          "method": "caribou.api.proto.MailboxService.ListLabels",
          "service": "gmail.googleapis.com"
        }
      }
    ]
  }
}

Steps to Reproduce the Problem

  1. Running quickstart.php exactly as given.

How to fix:

  1. Edit quickstart.php by setting the scopes to something usable:

$client->setScopes('https://www.googleapis.com/auth/gmail.modify');

Specifications

  • PHP version 7.4
  • WSL2 running Ubuntu 20.04 LTS

askew-etc avatar Jul 10 '22 02:07 askew-etc