擅长:python、mysql、java
<p>如果您将apiclient与本机restapi一起使用,那么它将如下所示。。。在</p>
<pre><code>from apiclient.discovery import build
import httplib2
from oauth2client.appengine import OAuth2Decorator
decorator = OAuth2Decorator(client_id=YOUR_GOOGLE_CLIENT_ID,
client_secret=YOUR_GOOGLE_CLIENT_SECRET,
scope=GOOGLE_SERVICE_SCOPE,
)
class MainHandler(webapp.RequestHandler):
@decorator.oauth_required
def get(self):
service = build(SERVICE_NAME,
SERVICE_VERSION,
http=decorator.http())
magic = service.method()
</code></pre>
<p>看看其他api的一些apiclient示例可能会有所帮助。例如,有一个很好的应用程序引擎与任务API集成的例子,它也使用OAuth2。在</p>
<p><a href="http://code.google.com/appengine/articles/python/getting_started_with_tasks_api.html" rel="nofollow">http://code.google.com/appengine/articles/python/getting_started_with_tasks_api.html</a></p>