asp.net web api2 - How to add parameters to redirect_uri in WebApi Oauth Owin authentication process? -
i'm creating webapi project oauth bearer token authenthication , external login providers (google, twitter, facebook etc.). started basic vs 2013 template , got work fine!
however, after user logs is, owin infrastructure creates redirect folllowing structure:
http://some.url/#access_token=<the access token>&token_type=bearer&expires_in=1209600
in server code want add additional parameter redirect because in registration process of app, new user needs first confirm , accept usage license before he/she registered user. therefore want add parameter "requiresconfirmation=true" redirect. however, i've no clue how this. tried setting authenticationresponsechallenge.properties.redirecturi of authenticationmanager doesn't seem have affect.
any suggestions appreciated!
it should relatively easy authorizationendpointresponse
notification:
in custom oauthauthorizationserverprovider
implementation, override authorizationendpointresponse
extract parameter ambient response grant, created when call iowincontext.authentication.signin(properties, identity)
. can add custom requiresconfirmation
parameter additionalresponseparameters
: automatically added callback url (i.e in fragment when using implicit flow):
public override task authorizationendpointresponse(oauthauthorizationendpointresponsecontext context) { var requiresconfirmation = bool.parse(context.owincontext.authentication.authenticationresponsegrant.properties.dictionary["requiresconfirmation"]); if (requiresconfirmation) { context.additionalresponseparameters.add("requiresconfirmation", true); } return task.fromresult<object>(null); }
in code calling signin
, determine whether user registered or not , add requiresconfirmation
authenticationproperties
container:
var properties = new authenticationproperties(); properties.dictionary.add("requiresconfirmation", "true"/"false"); context.authentication.signin(properties, identity);
feel free ping me if need more details.
Comments
Post a Comment