简体   繁体   English

Linq to Twitter-令牌无效/过期

[英]Linq to Twitter - Invalid / Expired Token

All, 所有,

I have the following code in a Windows Console Application. 我在Windows控制台应用程序中有以下代码。 I am using LinqtoTwitter ( http://linqtotwitter.codeplex.com/ ). 我正在使用LinqtoTwitter( http://linqtotwitter.codeplex.com/ )。 The line auth.IsAuthorized is returning true. 行auth.IsAuthorized返回true。 But it fails on the search with Invalid/Expired token error. 但是它在搜索中失败,并带有无效/过期的令牌错误。 I have checked and double-checked keys and tokens. 我已经检查并再次检查了密钥和令牌。 Any help would be greatly appreciated. 任何帮助将不胜感激。

    static void processTweets()
    {
        var auth = new SingleUserAuthorizer
        {
            Credentials = new InMemoryCredentials
            {
                ConsumerKey = Utility.GetSetting("ConsumerKey"),
                ConsumerSecret = Utility.GetSetting("ConsumerSecret"),
                AccessToken = Utility.GetSetting("Accesstoken"),
                OAuthToken = Utility.GetSetting("AccesstokenSecret")
            }
        };

        auth.Authorize();
        TwitterContext twitterCtx = new TwitterContext(auth);
        if (auth == null || !auth.IsAuthorized)
        {

        }

        var srch =
            (from search in twitterCtx.Search
             where search.Type == SearchType.Search &&
                   search.Query == "LINQ to Twitter" &&
                   search.Count == 7
             select search)
            .SingleOrDefault();

        Console.WriteLine("\nQuery: {0}\n", srch.SearchMetaData.Query);
        srch.Statuses.ForEach(entry =>
            Console.WriteLine(
                "ID: {0, -15}, Source: {1}\nContent: {2}\n",
                entry.StatusID, entry.Source, entry.Text));

    }

Your AccessToken and OAuthToken are backwards. 您的AccessToken和OAuthToken向后。 It might be easier to use SingleUserInMemoryCredentials. 使用SingleUserInMemoryCredentials可能会更容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Twitter API无效或令牌已过期 - Twitter API invalid or expired token 无效/过期的令牌-401-使用Spring.Social.Twitter未经授权(需要授权) - Invalid / expired Token - 401 - Unauthorized (Authorization Required) using Spring.Social.Twitter 无效或过期令牌返回错误 - Return error on invalid or expired token Sharepoint Provider托管的应用程序:无效的JWT令牌。 令牌已过期 - Sharepoint Provider Hosted App: Invalid JWT Token. The token is expired WCF Web服务中的安全上下文令牌无效或过期 - Invalid or expired security context token in WCF web service 未经授权。 访问令牌丢失、无效、受众不正确 (https://cognitiveservices.azure.com) 或已过期 - Unauthorized. Access token is missing, invalid, audience is incorrect (https://cognitiveservices.azure.com), or have expired 消息包含无效或过期的安全上下文令牌,或者因为绑定之间不匹配 - the message contains an invalid or expired security context token or because there is a mismatch between bindings 刷新过期令牌 Web API - Refresh expired token Web API 令牌已过期或撤销 - Token has been expired or revoked 令牌已过期-下一步该怎么做? - Token expired - what to do next?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM