c# - WebApi OAuth UseOAuthBearerAuthentication gives "Sequence contains more than one element" error -


i configured webapi oauth 2.0 these lines:

    app.useoauthbearerauthentication(new oauthbearerauthenticationoptions     {         provider = new oauthbearerauthenticationprovider(),     });      app.useoauthbearertokens(oauthoptions); 

but gives me following error @ each request :

message : error has occurred. exceptionmessage : sequence contains more 1 element exceptiontype : system.invalidoperationexception stacktrace :    @ system.linq.enumerable.singleordefault[tsource](ienumerable`1 source)    @ microsoft.owin.security.authenticationmanager.d__8.movenext() --- end of stack trace previous location exception thrown ---    @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task)    @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task)    @ system.runtime.compilerservices.taskawaiter`1.getresult()    @ system.web.http.hostauthenticationfilter.d__0.movenext() --- end of stack trace previous location exception thrown ---    @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task)    @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task)    @ system.web.http.controllers.authenticationfilterresult.d__0.movenext() --- end of stack trace previous location exception thrown ---    @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task)    @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task)    @ system.runtime.compilerservices.taskawaiter`1.getresult()    @ system.web.http.dispatcher.httpcontrollerdispatcher.d__1.movenext() 

my oauthoptions :

    oauthoptions = new oauthauthorizationserveroptions     {         tokenendpointpath = new pathstring("/token"),         provider = new applicationoauthprovider(publicclientid, usermanagerfactory),         authorizeendpointpath = new pathstring("/account/externallogin"),         accesstokenexpiretimespan = timespan.fromdays(14),         allowinsecurehttp = true,     }; } 

if comment useoauthbearerauthentication ok! didn't customize oauthbearerauthenticationprovider yet , use directly why give me error?

it should bug! use

app.useoauthauthorizationserver(oauthoptions);

instead of

app.useoauthbearertokens(oauthoptions);


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -