Get Bearer token without browser - api

I have an application where to test APIs, bearer token is obtained from browser console after logging in via SSO. Is there a way by which bearer token also could be obtained in a using API calls?
I am new to APIs and hence seeking your help

Related

Can the ASP.Net swagger UI (Swashbuckle.AspNetCore.SwaggerGen) be customized to get the credentials from the API user

I have seen a swagger UI with the Authorization button, which can get the user credentials, authorization flow, and client secrets then it will go and request the token from the auth server and use it in the next API calls. The UI is like this
I have used this approach in my ASP.net6 web API project (Swashbuckle.AspNetCore.SwaggerGen). But only manage to add a text box there to enter the bearer token, I have to get the Bearer token using a different mechanism. Can anyone help me to configure the swagger UI to something like above

Use Authentication (different Token) from Collection within Requests in Postman

I try to create a postman collection for my backend service which uses Azure B2C Authentication.
Within my Collection I added Authentication, which works and I can authenticate within my Chrome Browser:
Once I am authenticated and redirected back to Postman it says that an access_token can not be found. I can see that it is in id_token:
Now I created also a Request with Authentication Type oAuth 2.0 where I could select Available Token. But as the token is not within access_token it does not autofill the token. Is there any way to tell Postman that i want to use id_token as access_token within my requests in the collection?
Thanks for your help and feedback
As you saved your token with the name as Azure AD B2C Authentication, for your requests, you can select the Azure AD B2C Authentication from your available tokens.
This will auto-fill the token
I created the token with name as access token
Now for my request, I selected the access token from the available tokens under Access Token
Then the token is auto-filled as below
In this way, you can use the Access Token in collections in postman

Validate JWT Token from postman

JWT Token is generated in our application and using the same token within the expiration time I can call my API from postman also. I need to restrict that , so how can we identify if the API call with JWT token is coming from Postman or from browser and how to authenticate it in .net core ?

Using bearer authorization with PostMan

I am looking for an easy way to add bearer tokens to PostMan. I have imported my API into PostMan from a swagger definition, and am wondering if authorization can be added automatically to all requests in some easy way, such that I do not have to change the Authorization header for each endpoint whenever the token changes.
I am currently requesting a token at /token for my API by sending an x-www-form-urlencoded request containing the parameters username, password and grant_type with a password value.
The returned access_token is then appended to the Authorization header in the format "Bearer token-received-from-token-endpoint" for each request to the API.
The backend is implemented with AspNet Identity Framework and AspNet Web API 2.
Good approach here is chaining request
When you get a token, assign it to an environment variable and use that variable in your subsequent requests.
This way you will have a fresh token every time and your other requests can use that on runtime

Open Auth Authentication in ASP .NET Web Api

I am writing a ASP .NET WEB API Application which can be accessed by other devices and applications to interact with my Application hosted in IIS. How can I give OpenAuth Authentication for the WEB API Application. Am using MVC 4 in VS 2010 and hence my framework is 4.0. Please give me some suggestions.
You can authenticate a web API using Individual Accounts. Protected recource will contains the Www-Authenticate header with value "Bearer", indicating that the client must authenticate using a bearer token.
A bearer token is a particular type of access token. An access token is a credential string that authorizes a client to access a protected resource. (See RFC 6749.) A bearer token is an access token that can be used by any client. In other words, a client can use the token without proving that the token was issued to that particular client. (See RFC 6750.) For this reason, bearer tokens must be used with SSL. If you transmit a bearer token as plaintext, anyone can intercept it and get access to the protected resource.
All info about that can be found HERE