c# - Request additional claims Owin Security -
i trying retrieve additional information google oauth handshake using owin security.
i have following request user profile claim google , google permissions page reflects claim requested.
var googleconfig = new microsoft.owin.security.google.googleoauth2authenticationoptions { clientid = clientid", clientsecret = "secret" }; googleconfig.scope.add("https://www.googleapis.com/auth/userinfo.profile"); app.usegoogleauthentication(googleconfig);
however when response using authenticationmanager.getexternallogininfoasync();
there 1 name claim on user.
what need user profile data google on login?
you need access additional claims in provider's onauthenticate event. in there context param contains these additional properties asked in scopes. exmaple, when using facebook:
var fb = new facebookauthenticationoptions { appid = "...", appsecret = "...", authenticationtype = "facebook", signinasauthenticationtype = "externalcookie", provider = new facebookauthenticationprovider { onauthenticated = async ctx => { if (ctx.user["birthday"] != null) { ctx.identity.addclaim(new claim(claimtypes.dateofbirth, ctx.user["birthday"].tostring())); } } } }; fb.scope.add("user_birthday"); app.usefacebookauthentication(fb);
Comments
Post a Comment