Auth0 Home Blog Docs

Basic authentication on web api- .net core 2.0

auth0
api

#1

I have a web api which I can access it through Postman by using the token. (Bearer Token auth type).
What should I change in my API in order to be able to access my API with the Basic auth type(username and password).

Or even if it`s that possible?

Something like this:

I am not looking for a way to put authentication over my API!


#3

Hey there Alexandra! I would love to find out more about your API situation. How far are you into adding Basic Authentication to your .net core 2.0 API or are you currently reviewing possibilities before implementation? It is possible to add basic authentication to an API but I see you are not looking to add authentication directly over your API. I would be happy to help in any way I can!

Here’s a doc that many clients have found helpful in the past:


#4

Hello James,
Currently I have the API set to use the token received after a user login in a client app and auth0 gives me back a token.
Now I am trying to change that and to test how this will work if for example through Postman I send credentials of user (user created and saved in auth0) and based on that he should give me back access to my API.


#5

Hello,

I am trying to make a call to /token and based on the username and password he will return me back the token.
It’s that even possible to be made on the web api?


#6

Hi ,

The answer to this question is to use the Resource Owner Password Grant

NOTE: If trying to test this from Postman using the Auth0 Authentication Collection, you’ll need to add client_secret to the header collection.


#7

Thank you @marcus.baker for your help!

This is the answer and also for the ones who are working with .Net Core 2.0 when trying to implement this, pay attention at the pipelines order.

   app.UseAuthentication();    //need to be execued before MVC!

   app.UseMvc();

#8

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.