如何针对 Google Contacts API 向 Google 验证我的 Python 应用程序?

发布于 2024-11-29 16:56:03 字数 331 浏览 1 评论 0原文

我正在构建一个使用 Python gdata 库访问 Google 通讯录的应用程序,我需要通过该库进行身份验证才能使我的请求正常工作。我对此有点陌生,但基本上我正在构建一个在 cron 作业上运行的服务,以从 Google 中提取联系人,以便将它们备份到本地数据库。

在对 gdata.contacts.client.ContactsClient 对象运行 get_contacts() 之前,如何触发身份验证?有没有办法可以显示 WebKit 浏览器或使用默认浏览器来验证应用程序?除了身份验证之外,它将是一个在后台运行的命令行应用程序。我该怎么做?

I'm building an application which uses the Python gdata library to access Google Contacts and I need to authenticate via that library in order to make my requests work. I'm kind of new to this, but basically I'm building a service that runs on a cron job to pull contacts from Google in order to back them up to a local database.

How do I trigger the authentication before I run get_contacts() on the gdata.contacts.client.ContactsClient object? Is there a way I can display either a WebKit browser or use the default browser to authenticate the application? Other than the authentication, it'll be a command line application which will run in the background. How do I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你爱我像她 2024-12-06 16:56:03

这是针对 Google Docs 的,但我认为做法是相同的?

import gdata.docs.service

# Create a client class which will make HTTP requests with Google Docs server.
client = gdata.docs.service.DocsService()
# Authenticate using your Google Docs email address and password.
client.ClientLogin('[email protected]', 'password')

# Query the server for an Atom feed containing a list of your documents.
documents_feed = client.GetDocumentListFeed()
# Loop through the feed and extract each document entry.
for document_entry in documents_feed.entry:
  # Display the title of the document on the command line.
  print document_entry.title.text

详细信息:http://code.google.com/apis/gdata/articles/ python_client_lib.html

This is for Google Docs, but i think the practice is the same?

import gdata.docs.service

# Create a client class which will make HTTP requests with Google Docs server.
client = gdata.docs.service.DocsService()
# Authenticate using your Google Docs email address and password.
client.ClientLogin('[email protected]', 'password')

# Query the server for an Atom feed containing a list of your documents.
documents_feed = client.GetDocumentListFeed()
# Loop through the feed and extract each document entry.
for document_entry in documents_feed.entry:
  # Display the title of the document on the command line.
  print document_entry.title.text

More info: http://code.google.com/apis/gdata/articles/python_client_lib.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文