Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#Asp.net Linkedin授权使用Linkedintoolkit和DotNetOpenAuth_C#_Asp.net_Oauth_Linkedin_Oauth Provider - Fatal编程技术网

C#Asp.net Linkedin授权使用Linkedintoolkit和DotNetOpenAuth

C#Asp.net Linkedin授权使用Linkedintoolkit和DotNetOpenAuth,c#,asp.net,oauth,linkedin,oauth-provider,C#,Asp.net,Oauth,Linkedin,Oauth Provider,我试图授权我的ASP.net应用程序使用LinkdinAPI,但似乎无法正确验证。我希望有人能看看我的源代码,看看我可能做错了什么 首先,我试着按照这些步骤来做,虽然我在按照这些步骤做,但还是没有运气 按照我的理解,最简单的过程如下 创建DotNetOpenAuth的IConsumerTokenManager的实现 使用WebOAuthAuthorization类对我的应用程序进行授权,并为将来的API调用返回访问令牌 我的IConsumerTokenManager实现如下所示 出于显而易见的原

我试图授权我的ASP.net应用程序使用LinkdinAPI,但似乎无法正确验证。我希望有人能看看我的源代码,看看我可能做错了什么

首先,我试着按照这些步骤来做,虽然我在按照这些步骤做,但还是没有运气

按照我的理解,最简单的过程如下

  • 创建DotNetOpenAuth的IConsumerTokenManager的实现
  • 使用WebOAuthAuthorization类对我的应用程序进行授权,并为将来的API调用返回访问令牌 我的IConsumerTokenManager实现如下所示

    出于显而易见的原因,我在本例中添加了一个假的api密钥和密钥

    当调用“BeginAuthorization()”时,我被重定向到“授予K2PS发布者访问你的LinkedIn帐户”Patrick A 仅当您将您的LinkedIn网络信息信任此应用程序时才允许访问“LinkedIn”页面,然后单击“确定我将允许”,这将返回我的web应用程序。但是,如果我尝试返回字符串,则永远不会命中“\u completeAuthorization()”方法,并且其值为null

    同样值得注意的是,我的控制台输出在这个过程中引发了线程异常

    下面是我的控制台输出的副本

    mscorlib.dll中首次出现类型为“System.Threading.ThreadAbortException”的异常 mscorlib.dll中出现“System.Threading.ThreadAbortException”类型的异常,但未在用户代码中处理

    我是一个刚刚开始宣誓的人,但一直在讨论API,似乎无法解决这个问题。任何帮助都将不胜感激。

    您可以尝试我之前成功实现的

    您可以尝试我之前成功实现的

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using DotNetOpenAuth.OAuth.ChannelElements;
    using DotNetOpenAuth.OAuth.Messages;
    
    namespace UserLibrary.SocialMedia
    {
        public class ConsumerTokenManager : IConsumerTokenManager
        {
    
    
            private const string API_KEY = "ylk7j2jq4j7l";
            private const string SECRET_KEY = "WH3dlPFhPyWG0xlw";
    
            private Dictionary<string, string> tokensAndSecrets = new Dictionary<string, string>();
    
            public ConsumerTokenManager()
            {
                ConsumerKey = API_KEY;
                ConsumerSecret = SECRET_KEY;
            }
    
    
            #region ITokenManager Members
    
            public string ConsumerKey { get; private set; }
    
            public string ConsumerSecret { get; private set; }
    
            public string GetTokenSecret(string token)
            {
                return this.tokensAndSecrets[token];
            }
    
            public void StoreNewRequestToken(UnauthorizedTokenRequest request, ITokenSecretContainingMessage response)
            {
                this.tokensAndSecrets[response.Token] = response.TokenSecret;
            }
    
            public void ExpireRequestTokenAndStoreNewAccessToken(string consumerKey, string requestToken, string accessToken, string accessTokenSecret)
            {
                this.tokensAndSecrets.Remove(requestToken);
                this.tokensAndSecrets[accessToken] = accessTokenSecret;
            }
    
            /// <summary>
            /// Classifies a token as a request token or an access token.
            /// </summary>
            /// <param name="token">The token to classify.</param>
            /// <returns>Request or Access token, or invalid if the token is not recognized.</returns>
            public TokenType GetTokenType(string token)
            {
                throw new NotImplementedException();
            }
    
            #endregion
    
        }
    }
    
    ConsumerTokenManager consumerTokenManager = new ConsumerTokenManager();
                _webOAuthorization = new WebOAuthAuthorization(consumerTokenManager, _accessToken);
    
            _webOAuthorization.BeginAuthorize();
    
            _accessToken = _webOAuthorization.CompleteAuthorize();