如何使用Google plus的signin quota(plus.login scope)

2024-09-27 17:34:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我写了一个scraper来获取一些用户的公共内容。这个scraper获取评论、plusoners、resharers和用户的帖子。如果使用API密钥,则免费配额为10000个请求/天:

   service = apiclient.discovery.build(service_name, service_version,
                                             developerKey=api_key)

我想使用Sign-in quota获取plusoners和resharers(people.list API调用)。但是我不能用oauth来实现这个目的。也就是说,我没有任何用户。我想使用作用域(https://www.googleapis.com/auth/plus.login)来获取plusoners和resharers

在Java中,我认为这个过程是:https://developers.google.com/android/reference/com/google/android/gms/common/api/GoogleApiClient.Builder

我如何为Python做到这一点


Tags: 用户httpscomapi内容servicegoogle评论
1条回答
网友
1楼 · 发布于 2024-09-27 17:34:59

关于如何使用Oauth2.0对其进行身份验证,有很多文档,但是关于服务器端脚本如何在没有任何人在场的情况下对其自身进行身份验证的信息并不多

我想我找到了使用JWT最方便的方法

from apiclient.discovery import build
from httplib2 import Http
from oauth2client.client import SignedJwtAssertionCredentials

private_key = open("MyProject.p12").read() 
client_email = 'EMAIL'
http_auth = credentials.authorize(Http())
credentials = SignedJwtAssertionCredentials(client_email, private_key, 'https://www.googleapis.com/auth/plus.login')
service.people().list(userId='me', collection='connected').execute()

像我这样不小心的人注意:此外,此身份验证方法对我没有用处,因为它是针对people().list API调用的。但是,我想使用people().listByActivity

相关问题 更多 >

    热门问题