Hi @Mani kanta
Thanks for the question. it looks like you're using GCP and not Azure Web Pubsub. Please try posting on their community site to get the right assistance with your issue.
Best,
Grace
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi - I have created the images for gcp pubsub push subscriptions with this below code and created the end point through cloud run. I have pointed the endpoint push subscription. Here having the issue is end point not send the "[FromBody] PushBody body" body object and "[FromQuery] string token" is missing. If possible may i know the solution for this ?
Seems having any issue while creating the pub/sub push subscription.
[HttpPost]
[Route("/AuthPush")]
public async Task<IActionResult> AuthPushAsync([FromBody] PushBody body, [FromQuery] string token)
{
// Get the Cloud Pub/Sub-generated "Authorization" header.
string authorizaionHeader = HttpContext.Request.Headers["Authorization"];
_logger.LogInformation("Authorization is sucessful" + authorizaionHeader);
string verificationToken = token ?? body.message.attributes["token"];
_logger.LogInformation("Varifiacation token is assigned" + verificationToken);
// JWT token comes in `Bearer <JWT>` format substring 7 specifies the postion of first JWT char.
string authToken = authorizaionHeader.StartsWith("Bearer ") ? authorizaionHeader.Substring(7) : null;
if (string.IsNullOrEmpty(token))
_logger.LogInformation("token " + token);
//if (string.IsNullOrEmpty(body.ackId))
// _logger.LogInformation("AckId " + body.ackId);
//if (string.IsNullOrEmpty(body.message.messageId))
// _logger.LogInformation("Message Id " + body.message.messageId);
//if (string.IsNullOrEmpty(body.message.publishTime.ToString()))
// _logger.LogInformation("PublishTime " + body.message.publishTime.ToString());
if (string.IsNullOrEmpty(body.message.data))
_logger.LogInformation("Data " + body.message.data);
if (verificationToken != _options.VerificationToken || authToken is null)
{
return new BadRequestResult();
}
// Verify and decode the JWT.
// Note: For high volume push requests, it would save some network
// overhead if you verify the tokens offline by decoding them using
// Google's Public Cert; caching already seen tokens works best when
// a large volume of messages have prompted a single push server to
// handle them, in which case they would all share the same token for
// a limited time window.
var payload = await JsonWebSignature.VerifySignedTokenAsync<PubSubPayload>(authToken);
// IMPORTANT: you should validate payload details not covered
// by signature and audience verification above, including:
// - Ensure that `payload.Email` is equal to the expected service
// account set up in the push subscription settings.
// - Ensure that `payload.Email_verified` is set to true.
var messageBytes = Convert.FromBase64String(body.message.data);
string message = System.Text.Encoding.UTF8.GetString(messageBytes);
s_authenticatedMessages.Add(message);
return new OkResult();
}
Hi @Mani kanta
Thanks for the question. it looks like you're using GCP and not Azure Web Pubsub. Please try posting on their community site to get the right assistance with your issue.
Best,
Grace