Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.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
Oauth ProcessUserAuthorization上的DotNetOpenAuth错误请求_Oauth_Dotnetopenauth - Fatal编程技术网

Oauth ProcessUserAuthorization上的DotNetOpenAuth错误请求

Oauth ProcessUserAuthorization上的DotNetOpenAuth错误请求,oauth,dotnetopenauth,Oauth,Dotnetopenauth,我正在使用DotNetOpenAuth示例实现SSO过程(OAuth 2.0)。该解决方案有3个项目(客户端Web、授权服务器和资源服务器)。在授权服务器向客户端返回授权代码后,我在处理用户授权响应的步骤中遇到了一个问题 http://localhost/OAuthClient/SampleWcf2.aspx?code=xxx&state=L6SAxlXhlxwsBRcTCK3IAw 例外情况是: [WebException: The remote server returned an

我正在使用DotNetOpenAuth示例实现SSO过程(OAuth 2.0)。该解决方案有3个项目(客户端Web、授权服务器和资源服务器)。在授权服务器向客户端返回授权代码后,我在处理用户授权响应的步骤中遇到了一个问题

http://localhost/OAuthClient/SampleWcf2.aspx?code=xxx&state=L6SAxlXhlxwsBRcTCK3IAw
例外情况是:

[WebException: The remote server returned an error: (400) Bad Request.]
   System.Net.HttpWebRequest.GetResponse() +8765848
   DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request, DirectWebRequestOptions options) +271

[ProtocolException: Error occurred while sending a direct message or getting the response.]
   DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request, DirectWebRequestOptions options) +2261
   DotNetOpenAuth.Messaging.Channel.RequestCore(IDirectedProtocolMessage request) +516
   DotNetOpenAuth.Messaging.Channel.Request(IDirectedProtocolMessage requestMessage) +138
   DotNetOpenAuth.OAuth2.ClientBase.UpdateAuthorizationWithResponse(IAuthorizationState authorizationState, EndUserAuthorizationSuccessAuthCodeResponse authorizationSuccess) +210
   DotNetOpenAuth.OAuth2.WebServerClient.ProcessUserAuthorization(HttpRequestBase request) +904
   OAuthClient.SampleWcf2.Page_Load(Object sender, EventArgs e) +118
   System.Web.UI.Control.LoadRecursive() +71
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3178
这是我的密码:

protected void Page_Load(object sender, EventArgs e) {
            if (!IsPostBack) {
                // Check to see if we're receiving a end user authorization response.
                var authorization = Client.ProcessUserAuthorization();                
                //Temp
                if (authorization != null)
                {
                    // We are receiving an authorization response.  Store it and associate it with this user.
                    Authorization = authorization;
                    Response.Redirect(Request.Path); // get rid of the /?code= parameter
                }
            }

            if (Authorization != null) {
                // Indicate to the user that we have already obtained authorization on some of these.
                foreach (var li in this.scopeList.Items.OfType<ListItem>().Where(li => Authorization.Scope.Contains(li.Value))) {
                    li.Selected = true;
                }
                this.authorizationLabel.Text = "Authorization received!";
                if (Authorization.AccessTokenExpirationUtc.HasValue) {
                    TimeSpan timeLeft = Authorization.AccessTokenExpirationUtc.Value - DateTime.UtcNow;
                    this.authorizationLabel.Text += string.Format(CultureInfo.CurrentCulture, "  (access token expires in {0} minutes)", Math.Round(timeLeft.TotalMinutes, 1));
                }
            }

            this.getNameButton.Enabled = this.getAgeButton.Enabled = this.getFavoriteSites.Enabled = Authorization != null;
        }
受保护的无效页面加载(对象发送方,事件参数e){
如果(!IsPostBack){
//检查是否收到最终用户授权响应。
var authorization=Client.ProcessUserAuthorization();
//临时工
if(授权!=null)
{
//我们正在接收授权响应。请将其存储并与此用户关联。
授权=授权;
Response.Redirect(Request.Path);//去掉/?code=参数
}
}
if(授权!=null){
//向用户表明,我们已经获得了其中一些的授权。
foreach(此.scopeList.Items.OfType()中的var li,其中(li=>Authorization.Scope.Contains(li.Value))){
li.Selected=true;
}
this.authorizationLabel.Text=“已收到授权!”;
if(Authorization.AccessTokenExpirationUtc.HasValue){
TimeSpan timeLeft=Authorization.AccessTokenExpirationUtc.Value-DateTime.UtcNow;
this.authorizationLabel.Text+=string.Format(CultureInfo.CurrentCulture,“(访问令牌在{0}分钟内过期)”,Math.Round(timeLeft.TotalMinutes,1));
}
}
this.getNameButton.Enabled=this.getAgeButton.Enabled=this.getFavoriteSites.Enabled=Authorization!=null;
}

我将错误反馈编成代码段。URL也一样,因为点击它对其他人不起作用(`),所以根本不知道为什么会包含它。感谢永远不应该出现在一篇好帖子中:不要分心,不要闲聊(阅读)