【问题标题】:Google AdWords library doesn't create an access tokenGoogle AdWords 库不会创建访问令牌
【发布时间】:2018-04-18 18:29:00
【问题描述】:

我正在尝试对 Google AdWords 进行 targetingIdeaService API 调用。到目前为止,这是我的代码:

[HttpGet]
public IEnumerable<string> Get()
{
    var user = new AdWordsUser();

    using (TargetingIdeaService targetingIdeaService = (TargetingIdeaService)user.GetService(AdWordsService.v201802.TargetingIdeaService))
    {
        // Create selector.
        TargetingIdeaSelector selector = new TargetingIdeaSelector();
        selector.requestType = RequestType.IDEAS;
        selector.ideaType = IdeaType.KEYWORD;
        selector.requestedAttributeTypes = new AttributeType[] {
            AttributeType.KEYWORD_TEXT,
            AttributeType.SEARCH_VOLUME,
            AttributeType.AVERAGE_CPC,
            AttributeType.COMPETITION,
            AttributeType.CATEGORY_PRODUCTS_AND_SERVICES
        };

        // Set selector paging (required for targeting idea service).
        var paging = Paging.Default;
        // Create related to query search parameter.
        var relatedToQuerySearchParameter =
            new RelatedToQuerySearchParameter
            { queries = new String[] { "bakery", "pastries", "birthday cake" } };
        var searchParameters = new List<SearchParameter> { relatedToQuerySearchParameter };

        var page = new TargetingIdeaPage();
        page = targetingIdeaService.get(selector);
        return new string[] { "value1", "value2" };
    }
}

看起来没问题,最后编译,等等。但后来我进入了调试模式。我看到了这个:

如您所见,该变量没有访问令牌。其他数据来自app.config文件。

我很确定传入的密钥是正确的。

然后代码抛出著名的invalid_grand 错误。就我而言,我相信这是因为没有生成访问令牌。我是 AdWords 和 ASP.NET 的新手,所以我可能错过了一些东西,但我不知道是什么。

我用过 docs, Code Structure instructions,和 code examples 把它们放在一起。

【问题讨论】:

    标签: c# asp.net .net api google-api


    【解决方案1】:

    我的配置有误。我不得不使用隐身窗口重新创建所有凭据。如果您有任何问题,请在此处打开一个线程:https://groups.google.com/forum/#!forum/adwords-api

    【讨论】:

      猜你喜欢
      • 2016-09-12
      • 1970-01-01
      • 2017-06-09
      • 1970-01-01
      • 2015-04-12
      • 2011-10-22
      • 2015-04-24
      • 2013-05-26
      • 1970-01-01
      相关资源
      最近更新 更多