• Share
    • Twitter
    • LinkedIn
    • Facebook
    • Email
  • Feedback
  • Improve this Doc
Show / Hide Table of Contents

Create a Web API with JWT

DNN Version: 09.02.00
10/06/2021 • 1 minute to read
Contributors  david-poindexter
10/06/2021  • 1 minute to read  • Contributors  david-poindexter

When creating a Web API in DNN, you can specify an authentication method to be used with your web service. To do so, you simply need to add the [DnnAuthorize] attribute in your code.

A template for a DNN Web API using JWT authentication:

    [DnnAuthorize(AuthTypes = "JWT")]
    public class MyJwtTestController : DnnApiController
    {
        [HttpGet]
        public IHttpActionResult MyGetMethod()
        {
            // Add your API logic here.
            // Remember to check for authorization.
        }
    }

MyGetMethod is called, only if the client was authenticated through the JWT authentication handler, which must be enabled in the web.config file.

Back to top by the community, for the community... #DNNCMS