Bearer Token
See original GitHub issueI have this configuration:
services.ConfigureSwaggerGen(x =>
{
//x.DocumentFilter
x.SingleApiVersion(new Info
{
Version = "v1",
Title = "API",
Description = "API templates for app.",
TermsOfService = "None",
Contact = new Contact()
{
Email = "email@d.com",
Name = "vendor",
Url = "website",
},
License = new License()
{
Name = "dd",
Url = "https://ddd/support/license"
},
});
x.IncludeXmlComments(AppContext.BaseDirectory + @"/app.xml");
x.IgnoreObsoleteProperties();
x.IgnoreObsoleteActions();
x.DescribeAllEnumsAsStrings();
x.AddSecurityDefinition("Bearer", new ApiKeyScheme()
{
Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
Name = "Authorization",
In = "header",
Type = "apiKey"
});
});
There is no provision in UI for input of Bearer token?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:16 (2 by maintainers)
Top Results From Across the Web
Bearer Authentication
Bearer authentication (also called token authentication) is an HTTP authentication scheme that involves security tokens called bearer tokens.
Read more >What is Bearer token and How it works?
Bearer tokens are a much simpler way of making API requests, since they don't require cryptographic signing of each request.
Read more >OAuth 2.0 Bearer Token Usage
A Bearer Token is an opaque string, not intended to have any meaning to clients using it. Some servers will issue tokens that...
Read more >Generating and using app-only Bearer Tokens | Docs
A Bearer Token is a byte array of unspecified format that you generate using a script like a curl command. You can also...
Read more >What are Bearer Tokens? - YouTube
01:43 Proof of Possession would increase security Bearer tokens are commonly used for authorization and authentication on the web.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mjabian
I tried your solution, fortunately it worked for me with a minor change (not in your code). I used below part of your code
It creates an
Authorize
button in Swagger UI like below for meWhen I click this button, it opens up a popup where I was able to put JWT value. It didn’t work.
I observed the request using F12 tools and found that the required header was being added but suffix
bearer
was not added. So, I just put this manually in token value likebearer <token-here>
. And, yo, It worked!!.Thanks a lot to you.
@ajbeaven @Behnam-Emamian - to get this to work in 2.x, you need to accompany your scheme definition with a corresponding requirement to indicate that the scheme is applicable to all operations in your API:
NOTE: it turns out that the old UI worked without this despite being an incomplete description, as per the Swagger 2.0 spec. The new swagger-ui correctly requires this