public ActionResult Index() { var model = new TokenGenerationRequest { B2CTenant = ConfigurationManager.AppSettings["B2CTenant"], B2CPolicy = ConfigurationManager.AppSettings["B2CPolicy"], ClientId = ConfigurationManager.AppSettings["B2CClientId"], ReplyUrl = ConfigurationManager.AppSettings["B2CRedirectUri"] }; return(View(model)); }
public ActionResult GenerateToken(TokenGenerationRequest request) { Dictionary <string, string> claims = new Dictionary <string, string>(); if (request.Claim1Value != null) { claims[request.Claim1Name] = request.Claim1Value; } if (request.Claim2Value != null) { claims[request.Claim2Name] = request.Claim2Value; } if (request.Claim3Value != null) { claims[request.Claim3Name] = request.Claim3Value; } if (request.Claim4Value != null) { claims[request.Claim4Name] = request.Claim4Value; } if (request.Claim5Value != null) { claims[request.Claim5Name] = request.Claim5Value; } if (request.Claim6Value != null) { claims[request.Claim6Name] = request.Claim6Value; } if (request.Claim7Value != null) { claims[request.Claim7Name] = request.Claim7Value; } if (request.Claim8Value != null) { claims[request.Claim8Name] = request.Claim8Value; } string token = BuildIdToken(claims, request.ClientId); string Url = BuildInviteUrl(request.B2CTenant, request.B2CPolicy, request.ClientId, request.ReplyUrl, token); return(PartialView(new TokenGenerationResult { InviteLink = Url, TokenData = token })); }
public override async Task <TokenGenerationResponse> GenerateToken( TokenGenerationRequest request, ServerCallContext context) { var claims = new List <Claim>(); foreach (var claim in request.Claims) { claims.Add(new Claim(claim.Name, claim.Value)); } var jwt = this.jwtGeneration.Generate( claims ); return(await Task.FromResult(new TokenGenerationResponse { Jwt = jwt })); }