api - How to C# Core OAuth without external login panel -
i'm making api exact online website form. visitor fill in information , after visitor sends it. need send exact online account client. before need accesstoken. problem don't want give user login page exact gives me. i'm searching days find way skip login or enter login information backend (there 1 login, , login client).
now authorization thing new me. far know can call authorization settings startup this:
httpcontext.authentication.getauthenticateinfoasync("exactonline");
but loginscreen don't want. thing exact telling me do:
create app registration supports automated connection wizard (your provisioning process).
is there way send them login information , visitor doesn't see loginpage.
in startup.cs
var s = new oauthoptions{ authenticationscheme = "exactonline", clientid = "clientid", clientsecret = "clientsecret", callbackpath = new pathstring("/callback"), automaticauthenticate = true, automaticchallenge = true, authorizationendpoint = new uri(string.format("{0}/api/oauth2/auth", "https://start.exactonline.nl")).tostring(), tokenendpoint = new uri(string.format("{0}/api/oauth2/token", "https://start.exactonline.nl")).tostring(), //scope = { "identity", "roles" }, events = new oauthevents { oncreatingticket = context => { context.identity.addclaim(new claim("urn:token:exactonline", context.accesstoken)); return task.fromresult(true); } } }; app.useoauthauthentication(s); first had code, gives me null exception when put identity in claimprincipal, because claimsprincipal null , don't know why.
httpcontext.authentication.authenticateasync("exactonline"); var identity = new claimsidentity("exactonline",claimsidentity.defaultnameclaimtype, claimsidentity.defaultroleclaimtype); identity.label = "authentication"; identity.addclaim(new claim(claimtypes.name, "username?")); identity.addclaim(new claim(claimtypes.nameidentifier, "password?")); claimsprincipal.addidentity(identity); var test = httpcontext.authentication.signinasync("exactonline", claimsprincipal, new authenticationproperties() { ispersistent = false })); after tried following code, didn't work. code continue, test variable filled message: name 'innerexceptioncount' not exist in current context.
var identity = new claimsidentity("exactonline", claimsidentity.defaultnameclaimtype, claimsidentity.defaultroleclaimtype); identity.label = "authentication"; identity.addclaim(new claim("username", "username")); identity.addclaim(new claim("password", "password")); claimsprincipal claimsprincipal = new claimsprincipal(identity); var test = httpcontext.authentication.signinasync("exactonline", claimsprincipal, new authenticationproperties() { ispersistent = false }); someone know how solve problem?
Comments
Post a Comment