开发者

Class based GDClient use

I study the document about Google API auth. And I little bit confused.

In document written:

import gdata.gauth
import gdata.docs.client

CONSUMER_KEY = 'example.com'
CONSUMER_SECRET = 'abc123doremi'
SCOPES = ['https://docs.google.com/feeds/开发者_JAVA技巧', 'https://www.google.com/calendar/feeds/']  #     example of a multi-scoped token

client = gdata.docs.client.DocsClient(source='yourCompany-YourAppName-v1')

oauth_callback_url = 'http://%s/get_access_token' % self.request.host
request_token = client.GetOAuthToken(
    SCOPES, oauth_callback_url, CONSUMER_KEY, consumer_secret=CONSUMER_SECRET)

self.request.host are confused me. Should I inherit a class? What the class shoud be inherited?


When your code is called from a web request, self.request is request that came in. self.request.host is the hostname that the user called (i.e. your server).

So this code subsitutes your server name into the oauth_callback_url for sending to Google in the OAuth Request as the call back URL. If you don't want to do that, feel free to hardcode the URL of the callback URL.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜