Skip to content

Instantly share code, notes, and snippets.

@CoderBK
Created January 13, 2022 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CoderBK/2ac36078f3b14bfaf821bf3cda53173d to your computer and use it in GitHub Desktop.
Save CoderBK/2ac36078f3b14bfaf821bf3cda53173d to your computer and use it in GitHub Desktop.
/// <summary>
/// Use Attribute which will help to check token
/// </summary>
/// <param name="req"></param>
/// <param name="log"></param>
/// <returns></returns>
[FunctionName(nameof(HttpTriggerFunction.TestAuthorization))]
public IActionResult TestAuthorization(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req,
ILogger log,
[JWTAuthorization()] JWTClaim jwtClaim) {
log.LogInformation("C# HTTP trigger function processed a request.");
// Check token is valid or not
if (jwtClaim == null)
{
return new UnauthorizedObjectResult("Invalid token");
}
return new OkObjectResult("Valid Token");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment