getting 403 error on watch request on gmail API php

青春壹個敷衍的年華 提交于 2019-12-10 12:16:24

问题


I am trying to make watch request to gmail API but getting 403 error every time :- Error sending test message to Cloud PubSub projects/projectId/topics/topic : User not authorized to perform this action.

<?php
require_once __DIR__ . '/vendor/autoload.php';
$client = new Google_Client();
$client->setAuthConfig('/opt/lampp/htdocs/gmail-api/client_secret.json');
$client->setScopes(array("https://mail.google.com/", "https://www.googleapis.com/auth/gmail.compose", "https://www.googleapis.com/auth/gmail.modify", "https://www.googleapis.com/auth/gmail.readonly", "https://www.googleapis.com/auth/cloud-platform", "https://www.googleapis.com/auth/pubsub"));
$client->setIncludeGrantedScopes(true);
$client->setAccessType("offline");
$service = new Google_Service_Gmail($client);
$watchreq = new Google_Service_Gmail_WatchRequest();
$watchreq->setLabelIds(array('INBOX'));
$watchreq->setTopicName('projects/Id/topics/tid');
$msg = $service->users->watch('me', $watchreq);

来源:https://stackoverflow.com/questions/43472845/getting-403-error-on-watch-request-on-gmail-api-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!