Pathoschild / FluentHttpClient

A modern async HTTP client for REST APIs. Its fluent interface lets you send an HTTP request and parse the response in one go.
MIT License
345 stars 52 forks source link

how to with jwt ??? #95

Closed icetech233 closed 4 years ago

icetech233 commented 4 years ago

how to with jwt ??? IdentityServer4

Jericho commented 4 years ago

I don't understand your question. Can you explain?

Pathoschild commented 4 years ago

JWTs are usually sent as bearer tokens (though it depends on your server configuration). Once you create the token with a library like System.IdentityModel.Tokens.Jwt, you can set it for all requests:

client.SetBearerAuthentication(jsonWebToken);

Or for a single request:

Blog result = await new FluentClient("https://example.org/api")
   .GetAsync("blogs")
   .WithBearerAuthentication(jsonWebToken)
   .As<Blog>();