oauth - DotNetOpenAuth Bad Request on ProcessUserAuthorization -
i'm implementing sso process (oauth 2.0) using dotnetopenauth example. solution has 3 projects (client web, authorization server, , resource server) got issue in step of processing user authorization response after authorization server returned authorization code client.
http://localhost/oauthclient/samplewcf2.aspx?code=xxx&state=l6saxlxhlxwsbrctck3iaw
exception is:
[webexception: remote server returned error: (400) bad request.] system.net.httpwebrequest.getresponse() +8765848 dotnetopenauth.messaging.standardwebrequesthandler.getresponse(httpwebrequest request, directwebrequestoptions options) +271 [protocolexception: error occurred while sending direct message or getting 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
here's code:
protected void page_load(object sender, eventargs e) { if (!ispostback) { // check see if we're receiving end user authorization response. var authorization = client.processuserauthorization(); //temp if (authorization != null) { // receiving authorization response. store , associate user. authorization = authorization; response.redirect(request.path); // rid of /?code= parameter } } if (authorization != null) { // indicate user have obtained authorization on 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; }
Comments
Post a Comment