简体   繁体   English

Google for webmasters API:如何模拟使用服务器到服务器请求?

[英]Google for webmasters API: How to impersonate using server to server request?

I can access the list of websites with the google API for webmasters using an access token granted via web service request and now I'd like to do it via a server to server request .我可以使用通过web 服务请求授予的访问令牌访问带有谷歌 API 的网站列表,现在我想通过server to server request 进行访问

After giving the permission to a server account to access the list I cannot use setAssertionCredentials properly using the following scope:在授予服务器帐户访问列表的权限后,我无法使用以下范围正确使用setAssertionCredentials

'https://www.googleapis.com/auth/webmasters'

Case 1情况1

when impersonating the user account:模拟用户帐户时:

$cred->sub = 'user.account@gmail.com';

the PHP client returns PHP 客户端返回

'Error refreshing the OAuth2 token, message: '{ "error" : "unauthorized_client", "error_description" : "Unauthorized client or scope in request." }

Case 2案例二

Without impersonating the user account the PHP client get an empty array在不模拟用户帐户的情况下,PHP 客户端会得到一个空数组

Question

How to impersonate a user using a server to server Google for webmasters API request?如何模拟用户使用服务器为网站管理员 API 请求服务 Google?

Related contents without answer相关内容无答案

I would say that to do it via a server to server request would make some troubles.我会说通过服务器到服务器的请求来做到这一点会带来一些麻烦。

As you can get it via web service request, you can initiate an external trigger to your php function and put the data in json on Google Cloud Storage (GCS) as public , so you can access the data you need via a server to server request and delete it immediately when it is done.由于您可以通过网络服务请求获取它,因此您可以向您的 php 函数发起一个外部触发器,并将数据以 json 形式放在 Google Cloud Storage (GCS) 上作为 public ,这样您就可以通过服务器到服务器请求访问您需要的数据并在完成后立即删除它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM