Google AdWords库未创建访问令牌 [英] Google AdWords library doesn't create an access token

查看:107
本文介绍了Google AdWords库未创建访问令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to make a targetingIdeaService API call to Google AdWords. This is my code so far:

[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" };
    }
}

看起来不错,最后编译,依此类推.但是后来我进入了调试模式.我看到了:

it looks ok, compiles at last, and so on. But then I went into debug mode. And I saw this:

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

So as you can see, the variable doesn't have the access token. The other data comes from app.config file.

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

I am quite certain the keys passed in are correct.

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

Then the code throws the famous invalid_grand error. In my case, I believe that's because the access token is not being generated. I'm new to AdWords and ASP.NET, so I probably missed something, but I have no idea what.

我用了 文档代码结构说明,以及 代码示例可以全部说明在一起.

I used the docs, Code Structure instructions, and code examples to put it all together.

推荐答案

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

I had my configuration wrong. I had to recreate all the credentials using incognito window. If you have any issues just open a thread here: https://groups.google.com/forum/#!forum/adwords-api

这篇关于Google AdWords库未创建访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆