asp.net - How can I define the clientID (or other data) in a bearer / access token using OWIN -
i trying figure out how put clientid (or additional data might need) inside bearer/access token.
i using owin oauth create tokens. can add claims identity ticket ecnrypted/serialized token , passed client.
the client calls protected api , api de-serializes token , sets iprinciple user. identity object contains username, , scopes in claimsidentity.
i additional information, such clientid made request token in first place.
i can put data inside claim; works hack.
i've done quite bit of searching , not sure how, if possible, store additional data inside bearer/access token.
thanks in advance!
you can store in authenticationproperties
object code below:
var props = new authenticationproperties(new dictionary<string, string> { { "as:client_id", (context.clientid == null) ? string.empty : context.clientid }, { "username", context.username } }); var ticket = new authenticationticket(identity, props);
and read need unprotect token code below read properties ticket. id din't find direct way create token without passing token, know not ultimate answer might help.
string token = "token goes here"; microsoft.owin.security.authenticationticket ticket = startup.oauthbeareroptions.accesstokenformat.unprotect(token);
Comments
Post a Comment