Carapacik / swagger_parser

Dart package that takes an OpenApi definition file and generates REST clients based on retrofit and data classes for your project.
https://pub.dev/packages/swagger_parser
MIT License
90 stars 38 forks source link

How to handle authorization? #145

Closed SasLuca closed 8 months ago

SasLuca commented 8 months ago

How can we handle authorization for endpoints that require say a jwt token?

It seems like the generated functions don't allow us to specify custom headers. Is there a way to at least specify certain headers per endpoint?

StarProxima commented 8 months ago

Use dio Interceptors to add a token to each request

SasLuca commented 8 months ago

Thanks for the answer.

I thought of doing this though it seemed better to me to only send the tokens with requests that need it. Sometimes endpoints can also return different things based on whether there is or isn't an auth token but in my case that isn't a thing.

Will mark as closed for the moment.