def get(self):
    """Handle get request."""
    client_customer_id = self.request.get('clientCustomerId')

    template_values = {
        'back_url': '/showAccounts',
        'back_msg': 'View Accounts.',
        'ccid': client_customer_id,
        'logout_url': users.create_logout_url('/'),
        'user_nickname': users.get_current_user().nickname()
    }

    try:
      try:
        app_user = InitUser()

        # Load Client instance.
        handler = APIHandler(app_user.client_id,
                             app_user.client_secret,
                             app_user.refresh_token,
                             app_user.adwords_manager_cid,
                             app_user.developer_token)

        campaigns = handler.GetCampaigns(client_customer_id)
      except Exception as e:
        template_values['error'] = str(e)
    finally:
      # Use template to write output to the page.
      template_values['campaigns'] = campaigns
      path = os.path.join(os.path.dirname(__file__),
                          '../templates/show_campaigns.html')
      self.response.out.write(template.render(path, template_values))
    def get(self):

        adwords_client = adwords.AdWordsClient.LoadFromStorage(
            'googleads.yaml')
        path = os.path.join(os.path.dirname(__file__), '../googleads.yaml')
        stream = open(path, 'r')
        authTokens = yaml.load(stream)

        client_customer_id = authTokens.get('adwords').get(
            'client_customer_id')
        client_id = authTokens.get('adwords').get('client_id')
        developer_token = authTokens.get('adwords').get('developer_token')
        client_secret = authTokens.get('adwords').get('client_secret')
        data = []

        try:
            try:
                # Load Client instance.
                handler = APIHandler(client_id, client_secret, developer_token)

                campaigns = handler.GetCampaigns(client_customer_id)

                for campaign in campaigns:
                    data.append(campaign.name)

            except Exception, e:
                data.append(str(e))
        finally:
            self.response.headers['Content-Type'] = 'application/json'
            self.response.out.write(json.dumps(data))