Hello, Have you tried using the GData client library<http://code.google.com/p/gdata-python-client/>for which a developer's guide<http://code.google.com/apis/calendar/data/2.0/developers_guide_python.html>on how to consume the Google Calendar API is available?
There's also an example on how to get an OAuth token here<http://code.google.com/apis/gdata/docs/auth/oauth.html#Examples> . Best, Alain On Sat, Sep 17, 2011 at 8:53 AM, Eby Chembola <[email protected]> wrote: > I'm facing an issue with calendar API, it returns and 401 error in half of > the times.. > When i tried to use the same authentication header in a REST client for > testing purpose it is working fine. > I'm using oauth1.0 for google calenders > language:python > > here is the piece of code I'm using > > > url_params = {} > url_params['alt']='json' > url_params['max-results']= str(max_result) > if startindex != '0': > url_params['start-index']= startindex > oauth_params = {} > FillInCommonOauthParams(oauth_params, consumer) > if access_token.key: > oauth_params['oauth_token'] = access_token.key > signed_params = oauth_params.copy() > signed_params.update(url_params) > request_url_base = ( > 'https://www.google.com/m8/feeds/contacts/default/full/') > base_string = GenerateSignatureBaseString( > method, > request_url_base, > signed_params) > > signature = GenerateOauthSignature(base_string, consumer.secret, > access_token.secret) > oauth_params['oauth_signature'] = signature > > > formatted_params = [] > for k, v in sorted(oauth_params.iteritems()): > formatted_params.append('%s="%s"' % (k, UrlEscape(v))) > param_list = ','.join(formatted_params) > if url_params: > request_url = '%s?%s' % (request_url_base, > FormatUrlParams(url_params)) > else: > request_url = request_url_base > > preencoded = '%s %s %s' % (method, request_url, param_list) > > req = urllib2.Request(request_url) > autheri = 'OAuth '+param_list > req.add_header('Authorization',autheri ) > r = urllib2.urlopen(req) > datas = json.loads(r.read()) > > -- > You received this message because you are subscribed to the Google > Groups "Google Calendar Data API" group. > To post to this group, send email to > [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://code.google.com/apis/calendar/community/forum.html > -- Alain Vongsouvanh | Developer Programs Engineer -- You received this message because you are subscribed to the Google Groups "Google Calendar Data API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://code.google.com/apis/calendar/community/forum.html
