I am creating a django application that creates a calendar and a Google docs folder for users, and uses the API to insert events and add documents. A few months ago, he worked quite well; now I am doing a great refactoring of my code and, testing the above components, I found that they no longer work! When I try to create a folder or calendar, I get this response from the API:
RequestError: {'status': 401, 'body': '<HTML>\n<HEAD>\n<TITLE>Unknown authorization header</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Unknown authorization header</H1>\n<H2>Error 401</H2>\n</BODY>\n</HTML>\n', 'reason': 'Unknown authorization header'}
My code is as follows: this example in Google documentation is (the document code is shorter, so I insert this one, although the authentication bit is actually a feature common to both):
from gdata.auth import OAuthSignatureMethod, OAuthToken, OAuthInputParams from gdata.calendar.service import CalendarService from django.conf import settings client_instance = CalendarService() client_instance.SetOAuthInputParameters(OAuthSignatureMethod.HMAC_SHA1, settings.OAUTH_CONSUMER_KEY, consumer_secret=settings.OAUTH_CONSUMER_SECRET) user_tokens = UserToken.objects.get(user=user) if not user_tokens.oauth_access_token_value or not user_tokens.oauth_valid_token: raise Exception('The user has not allowed us to access his services') oauth_token=OAuthToken(key=user_tokens.oauth_access_token_value, secret=user_tokens.oauth_access_token_secret) oauth_token.oauth_input_params = OAuthInputParams(OAuthSignatureMethod.HMAC_SHA1, settings.OAUTH_CONSUMER_KEY, consumer_secret=settings.OAUTH_CONSUMER_SECRET) client_instance.SetOAuthToken(oauth_token) new_folder = docs_service.CreateFolder("some folder")
The exception comes from this last line, has something changed in the API or is it just me? (I bet only me, but I donβt see this since it worked a couple of months ago)
source share