<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D50Z00008Ggq5JSAROkta Classic EngineAdministrationAnswered2023-06-01T20:10:12.000Z2018-08-22T13:54:02.000Z2018-09-13T20:57:02.000Z
dotnet core 2 webapi jwt login logout swagger ui

Hi,

 

I cannot find an example on how to implement JWT Tokens correctly into an dotnet core 2.1 webapi with a login (and logout) action that returns a JWT Token.

 

Login action would provide the JWT token if given the correct loging credentials : email and password

 

In my startup.cs i;m using:

 

      services.AddAuthentication(options =>

        {

          options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;

          options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;

          options.DefaultSignInScheme = JwtBearerDefaults.AuthenticationScheme;

        })

        .AddOktaWebApi(new OktaWebApiOptions()

        {

          ClientId = "***************",//Configuration["Okta:ClientId"],

          OktaDomain = "****************",//Configuration["Okta:OktaDomain"],

          AuthorizationServerId = "****************" //Configuration["Okta:AuthorizationServerId"]

        });

 

And I configured swagger ui to add a bearer token so that if i use the login action correctly i would retrieve a JWT token from some Okta service, and this is the point where I don't known what to use in the okta services stack? Which i then can use to authorize for actions that need authorization.

 

Hope this is clear enough, the examples i found don't include a sort of standalone webapi login action/functionality that uses Okta service(s).

 

The frontend will be an Angular 6 application that uses the login action and the returned JWT Token to authenticate for the private webapi calls.

 

Hope this makes sense ;)


  • mike.davie1.5312945692819849E12 (Customer First Programs)

    Hello Frank,

     

    Thanks for posting your inquiry in Okta Community Portal.

     

    If you receive a great answer to your question(s), please help readers find it by marking it the best answer. Hover over the answer and click "Best Answer." 

     

    Thank you,

    Mike Davie

    Okta Help Center

    Expand Post
This question is closed.
Loading
dotnet core 2 webapi jwt login logout swagger ui