From: vagrant Date: Mon, 14 Oct 2013 15:16:26 +0000 Subject: Updating to make sure we ALWAYS refresh the token X-Git-Url: http://maxious.lambdacomplex.org/git/?p=ckanext-ga-report.git&a=commitdiff&h=cdc8fb263c6f182d4e4a0cb6fe5354caf6cea042 --- Updating to make sure we ALWAYS refresh the token --- --- a/ckanext/ga_report/download_analytics.py +++ b/ckanext/ga_report/download_analytics.py @@ -193,10 +193,6 @@ # Supported query params at # https://developers.google.com/analytics/devguides/reporting/core/v3/reference try: - # Because of issues of invalid responses, we are going to make these requests - # ourselves. - headers = {'authorization': 'Bearer ' + self.token} - args = {} args["sort"] = "-ga:pageviews" args["max-results"] = 100000 @@ -208,16 +204,11 @@ args["filters"] = query args["alt"] = "json" - r = requests.get("https://www.googleapis.com/analytics/v3/data/ga", params=args, headers=headers) - if r.status_code != 200: - raise Exception("Request with params: %s failed" % args) - - results = json.loads(r.content) - print len(results.keys()) - except Exception, e: - log.exception(e) - #return dict(url=[]) - raise e + results = self._get_json(args) + + except Exception, e: + log.exception(e) + return dict(url=[]) packages = [] log.info("There are %d results" % results['totalResults'])