c# - "username/password couple is invalid" -
trying sign in user using postman. have implemented openiddict authentication solution using oauth2 token validation middelware. when im trying access, following error message:
username/password couple invalid
i have following test user.
using (var servicescope = app.applicationservices.getrequiredservice<iservicescopefactory>().createscope()) { var db = servicescope.serviceprovider.getservice<applicationdbcontext>(); db.database.ensuredeleted(); db.database.ensurecreated(); var user = new user(); var hasher = new passwordhasher<user>(); db.addrange( new applicationuser { firstname = "thomas", lastname = "smith", username = "user@test.com", email = "user@test.com", passwordhash = hasher.hashpassword(user, "password1") }, ); db.savechanges(); }
when debug in authorizationcontroller, user variable turns out null though input variable correct.
if (request.ispasswordgranttype()) { var user = await _usermanager.findbynameasync(request.username); if (user == null){ return badrequest(new openidconnectresponse { error = openidconnectconstants.errors.invalidgrant, errordescription = "the username/password couple invalid." }); }
do have code in async method? guess it's not blocking on await, , testing if user == null before user lookup returns. try adding delay in there , see if changes it.
Comments
Post a Comment