我可以使用通过网络服务请求授予的访问 token 访问网站管理员的 google API 网站列表,现在我想通过服务器到服务器请求来完成.
在授予服务器帐户访问列表的权限后,我无法使用以下范围正确使用 setAssertionCredentials
:
'https://www.googleapis.com/auth/webmasters'
案例一
模拟用户帐户时:
$cred->sub = 'user.account@gmail.com';
PHP 客户端返回
'Error refreshing the OAuth2 token, message: '{ "error" : "unauthorized_client", "error_description" : "Unauthorized client or scope in request." }
案例二
如果不模拟用户帐户,PHP 客户端会得到一个空数组
问题
如何使用服务器模拟用户向 Google 发送网站管理员 API 请求?
没有回答的相关内容
最佳答案
我会说通过服务器到服务器的请求来完成它会带来一些麻烦。
因为您可以通过网络服务请求获得它,您可以启动一个外部触发器到您的 php 函数和 put the data in json on Google Cloud Storage (GCS) as public ,因此您可以通过服务器到服务器请求访问所需的数据,并在完成后立即将其删除。
关于php - 谷歌网站管理员 API : How to impersonate using server to server request?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30286479/