有哪些方法可以使用python和oauth2.0导入谷歌联系人?
我们成功获得了凭据,我们的应用程序请求访问联系人,但在获得凭据后,我找不到发现联系人api的方法.
所以像:
from apiclient.discover import build
import httplib2
http = httplib2.Http()
#Authorization
service = build("contacts", "v3", http=http)
Run Code Online (Sandbox Code Playgroud)
给我们UnknownApiNameOrVersion例外.看起来联系人API不在apiclient支持的API列表中.
我正在寻找替代方法.
python google-api contacts oauth-2.0 google-api-python-client
我有以下代码,我不知道如何打印下一页的链接,如何进入下一页?
#!/usr/bin/python2.4
# -*- coding: utf-8 -*-
import pprint
from apiclient.discovery import build
def main():
service = build("customsearch", "v1",
developerKey="")
res = service.cse().list(
q='lectures',
cx='013036536707430787589:_pqjad5hr1a',
num=10, #Valid values are integers between 1 and 10, inclusive.
).execute()
for value in res:
#print value
if 'items' in value:
for results in res[value]:
print results['formattedUrl']
if __name__ == '__main__':
main()
Run Code Online (Sandbox Code Playgroud) 我想抓取200个结果大约2000个查询,但它给了我"超出每日限制"的错误.
我想确认每天可以抓取多少结果.有没有解决方案可以解决这个问题?或者唯一的方法是每天抓取一小部分查询......?
我抓取谷歌的代码如下:
def crawl(query_list):
http = httplib2.Http()
# Construct the service object for the interacting with the CustomSearch API.
service = discovery.build('customsearch', 'v1', developerKey='my api key', http=http)
res_list = []
for query in query_list:
json_res = service.cse().list(q = query, cx = 'my search engine id', num = 200,).execute()
res_list.append(json_res)
Run Code Online (Sandbox Code Playgroud)
谢谢!
我正在开发一个 python 脚本,它将文件上传到我的驱动器中的特定文件夹,正如我注意到的那样,驱动器 api 为此提供了一个很好的实现,但我确实遇到了一个问题,我如何一次删除多个文件?
我尝试从驱动器中抓取我想要的文件并组织它们的 ID,但没有运气......(下面的片段)
dir_id = "my folder Id"
file_id = "avoid deleting this file"
dFiles = []
query = ""
#will return a list of all the files in the folder
children = service.files().list(q="'"+dir_id+"' in parents").execute()
for i in children["items"]:
print "appending "+i["title"]
if i["id"] != file_id:
#two format options I tried..
dFiles.append(i["id"]) # will show as array of id's ["id1","id2"...]
query +=i["id"]+", " #will show in this format "id1, id2,..."
query = query[:-2] #to …Run Code Online (Sandbox Code Playgroud) python google-api delete-file google-drive-api google-api-python-client
我正在使用OAuthlib进行Google的OAuth流程。运行4到5个月效果良好。突然我开始出现以下错误:
File "/home/whitesnow-2/Gaurav/Axonator/AxVirtualEnv/local/lib/python2.7/site-packages/oauthlib/oauth2/rfc6749/parameters.py",
line 409, in validate_token_parameters raise w Warning: Scope has changed from
"https://www.googleapis.com/auth/calendar
https://www.googleapis.com/auth/docs
https://www.googleapis.com/auth/spreadsheets
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/userinfo.profile" to
"https://www.googleapis.com/auth/calendar
https://www.googleapis.com/auth/docs
https://www.googleapis.com/auth/spreadsheets
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/userinfo.profile".
Run Code Online (Sandbox Code Playgroud)
以下是用于生成OAuth授权URL的代码:
flow = google_auth_oauthlib.flow.Flow.from_client_secrets_file(
settings.GOOGLE_OAUTH2_CLIENT_SECRETS_JSON,
scopes=['https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/docs https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile'],
redirect_uri=REDIRECT_URI
)
authorization_url, state = flow.authorization_url(
access_type='offline',
include_granted_scopes='true',
prompt='consent'
)
Run Code Online (Sandbox Code Playgroud)
以下是Google OAuth回调的代码:
auth_code = request.GET.get("code")
objectid = request.GET.get("state")
error = request.GET.get("error")
if error == "access_denied":
return "Access Denied"
else:
flow = google_auth_oauthlib.flow.Flow.from_client_secrets_file(
settings.GOOGLE_OAUTH2_CLIENT_SECRETS_JSON,
scopes=['https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/docs https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile'],
redirect_uri=REDIRECT_URI
)
flow.fetch_token(code=auth_code)
Run Code Online (Sandbox Code Playgroud) python python-2.7 google-oauth google-api-python-client django-1.7
当我将 xlsx 文件与我的代码一起上传到 Google Drive 时,我想将它们自动转换为 Google 电子表格。但是,虽然转换成功用于 csv 文件,但我得到:
<HttpError 400 when requesting https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable&alt=json returned "Bad Request">
Run Code Online (Sandbox Code Playgroud)
尝试上传 xlsx 时。
这是我的代码:
def upload_service(filepath, name="", description="", fileID="", parentID=""):
""" Uses a Resource (service) object to upload a file to drive. """
if service == "": authenticate_service()
if name == "":
name = str(os.path.basename(filepath).split(os.extsep)[0]) # Get from filepath
extension = str(os.path.basename(filepath).split(os.extsep)[1]).lower()
if extension == "csv": # CSV
mime_type = "text/csv"
elif extension in ["xls", "xlsx"]: # EXCEL
mime_type = "application/ms-excel"
else: …Run Code Online (Sandbox Code Playgroud) python excel google-api google-drive-api google-api-python-client
我正在尝试使用 python BigQuery API 查询表并将结果存储在另一个 BigQuery 表中。但是当我在查询部分使用标准 SQL 时,它会抛出无效的表名错误。如何在 BigQuery API 中使用标准 SQL?我正在使用气流 BigQuery 挂钩
'configuration': {
'query': {
'destinationTable': {
'tableId': u 'our_table_name',
'datasetId': 'our_dataset_id',
'projectId': 'our_project_id'
},
'useLegacySql': False,
'allowLargeResults': True,
'writeDisposition': 'WRITE_TRUNCATE',
'query': u'SELECT * FROM `projectID.datasetId.tablename`',
}
}
Run Code Online (Sandbox Code Playgroud)
Exception: BigQuery job failed. Final error was: {u'reason': u'invalid', u'message': u'Invalid table name: `projectId:datasetId.tableId`', u'location': u'`projectId:datasetId.tableId`'}.
Run Code Online (Sandbox Code Playgroud) 我继Quickstart上https://developers.google.com/drive/api/v3/quickstart/python。我已经通过页面启用了驱动器 API,加载了credentials.json并且可以成功地列出我的谷歌驱动器中的文件。但是,当我想下载文件时,我收到了消息
`The user has not granted the app ####### read access to the file`
Run Code Online (Sandbox Code Playgroud)
我需要做的不仅仅是将该范围放入我的代码中,还是需要激活其他东西?
SCOPES = 'https://www.googleapis.com/auth/drive.file'
client.flow_from_clientsecrets('credentials.json', SCOPES)
Run Code Online (Sandbox Code Playgroud) python google-drive-api google-oauth google-api-python-client
Google Play 管理中心中的 Google Play 电子邮件列表管理区域允许管理员输入逗号分隔的电子邮件地址或上传 CSV。Google Play Console 提供了一个 httpPOST到https://play.google.com/apps/publish/testersemaillist?account={account}
是否可以通过 API 管理这些列表?上面的似乎不适合非谷歌使用。
我看到有一个 Google Play 开发者 API,但我没有看到任何看起来允许管理电子邮件列表的内容。 这是我发现的最接近的东西,它允许更新与测试跟踪相关的 Google 网上论坛或 Google+ 社区,但不能更新电子邮件列表。
以下是将 Beta 测试人员添加到 Test Flight 的文档:
google-api google-api-python-client google-play-developer-api google-play-console
升级到新的google-api-python-client1.8.1 后,我收到此错误。我们知道 python 3.8 是否打破了最新版本google-api-core?以及是否有解决方案
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/base.py", line 129, in init_process
self.load_wsgi()
File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
return self.load_wsgiapp()
File "/usr/local/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python3.8/site-packages/gunicorn/util.py", line 350, in import_app
__import__(module)
File "/prosebit/prosebit/app.py", line 10, in <module>
from prosebit.blueprints.page import page
File …Run Code Online (Sandbox Code Playgroud) python ×9
google-api ×5
google-oauth ×2
airflow ×1
contacts ×1
delete-file ×1
django-1.7 ×1
excel ×1
oauth-2.0 ×1
python-2.7 ×1