c# - OAuthWebSecurity doesnt work -
i develop our application , allows user login via facebook, microsoft, google, twitter , linkedin.
in globas.asax registering services:
protected void application_start(object sender, eventargs e) { bundletable.enableoptimizations = !httpcontext.current.isdebuggingenabled; bundleconfig.registerbundles(bundletable.bundles); scriptmanager.scriptresourcemapping.adddefinition("jquery", new scriptresourcedefinition { path = "~/scripts/jquery-1.10.2.min.js", debugpath = "~/scripts/jquery-1.10.2.js" }); this.registerauthenticationproviders(); } private void registerauthenticationproviders() { oauthwebsecurity.registerfacebookclient("key1", "key2", "facebook"); oauthwebsecurity.registergoogleclient("google"); oauthwebsecurity.registerlinkedinclient("key1", "key2", "linkedin"); oauthwebsecurity.registermicrosoftclient("key1", "key2", "microsoft"); oauthwebsecurity.registertwitterclient("key1", "key2", "twitter"); }
at click of button calls appropriate method:
oauthwebsecurity.requestauthentication("servicename", string.format("~/login.ashx"));
servicenames are:microsoft, google, linkedin, facebook or twitter according button pressed.
handler login.aspx like:
public bool isreusable { { return false; } } public void processrequest(httpcontext context) { var result = oauthwebsecurity.verifyauthentication(); if (result.issuccessful) { var service = (loginservices)enum.parse(typeof(loginservices), result.provider, true); //find user in db, if not find create , login @ last this.trylogin(result, context, service); this.redirectrequest(context); } else { // login failed dblogger.writelog(logpriority.fatal, string.format("{0}-{1}_1", this.gettype().name, "processrequest"), result.error); this.redirectrequest(context, errormessages.loginfailed); } }
facebook: fine , working correctly
microsoft: redirect login fine, in return return error:
the remote server returned error: (400) bad request. description: unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code. exception details: system.net.webexception: remote server returned error: (400) bad request. source error: unhandled exception generated during execution of current web request. information regarding origin , location of exception can identified using exception stack trace below. stack trace: [webexception: remote server returned error: (400) bad request.] system.net.httpwebrequest.getresponse() +6442312 dotnetopenauth.aspnet.clients.microsoftclient.queryaccesstoken(uri returnurl, string authorizationcode) +334 dotnetopenauth.aspnet.clients.oauth2client.verifyauthentication(httpcontextbase context, uri returnpageurl) +142 dotnetopenauth.aspnet.openauthsecuritymanager.verifyauthentication(string returnurl) +239 microsoft.web.webpages.oauth.oauthwebsecurity.verifyauthenticationcore(httpcontextbase context, string returnurl) +129 microsoft.web.webpages.oauth.oauthwebsecurity.verifyauthentication(string returnurl) +86 login.processrequest(httpcontext context) +18 system.web.callhandlerexecutionstep.system.web.httpapplication.iexecutionstep.execute() +341 system.web.httpapplication.executestep(iexecutionstep step, boolean& completedsynchronously) +69
google , linkedin: click on link report javascript error: sys.webforms.pagerequestmanagerservererrorexception: unknown error occurred while processing request on server. status code returned server was: 0
twitter click on link report javascript error:
sys.webforms.pagerequestmanagerservererrorexception: error occurred while sending direct message or getting response.
the buttons register onclick envet in oninit event in page.
do have idea why code not work? thanks
update
problem solved. imagebuttons in updatepanel
for linkedin, update package, work sure.
update-package dotnetopenauth.core
hit 'enter' , enjoy.
Comments
Post a Comment