protected void Page_Load(object sender, EventArgs e) { //obtain the berer token bearerId = AzureJwt.token(); //Response.Redirect("www.bing.com?" + bearerId); Getsubscription(); }
private string GenerateAmrockJwt(string azureToken, List <Claim> claims = null) { var secretKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_jwtOptions.SigningKey)); var signinCredentials = new SigningCredentials(secretKey, SecurityAlgorithms.HmacSha256); var tokenHandler = new JwtSecurityTokenHandler(); //parse asure token json AzureJwt azureJwt = JsonSerializer.Deserialize <AzureJwt>(azureToken); //create list of claims, with the azure refresh token included claims = claims ?? new List <Claim>(); claims.AddRange(new List <Claim>() { new Claim("AzureRefresh", azureJwt.refresh_token), new Claim("AzureToken", azureJwt.access_token) }); var tokeOptions = new JwtSecurityToken( issuer: _jwtOptions.Issuer, audience: _jwtOptions.Audience, claims: claims, expires: DateTime.Now.AddSeconds(int.Parse(azureJwt.expires_in) - 60), //set expiration to expire before the azure token would signingCredentials: signinCredentials ); var tokenString = tokenHandler.WriteToken(tokeOptions); return(tokenString); }