[BUG] [swift5] Update the Swift 5 bearer token authentication examples
See original GitHub issueThe following examples are outdated with respect to the current Swift 5 implementation. The primary issue here is that the execute method nowadays returns URLSessionTask?
whereas the examples are working with Void
as the return type.
I’ve tried to update the examples to get a working implementation myself, alas, I don’t quite understand how to do it.
- Wiki: https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-do-i-implement-bearer-token-authentication-with-urlsession-on-the-swift-api-client
- Example source code: https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/swift5/urlsessionLibrary/SwaggerClientTests/SwaggerClient/BearerDecodableRequestBuilder.swift
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
How to Implement Basic Authentication in Swift - Cocoacasts
In this episode, you learn how to authenticate a user using basic authentication, or basic auth for short, in Swift. We use the...
Read more >How to program the refresh token logic when using Swift ...
Basically, if I get 401 in any request, I try to download the access token using the refresh token. If unauthorized, I logout...
Read more >Swift 5 URLRequest authorization header: reserved, how to set?
Here, token is a method as an example to authenticate a user. I pass something like that from the UI to this method...
Read more >Building a token refresh flow with async/await and Swift ...
Refreshing authentication tokens is something that a lot of us deal with regularly, and doing it correctly can be a pretty challenging task....
Read more >Authentication with signed requests in Alamofire 5 - SwiftLee
In this example, we're adding a JSON Web Token (JWT) as an authentication header to each request that requires to be authenticated.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop 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
Top GitHub Comments
I think I found a solution inspired in RxSwift/Combine, instead of returning URLSessionTask we would return a OpenAPIRequestCancelable, similar to Combine AnyCancellable, that have a private property URLSessionTask that is updated accordingly to the current request. What do you think? I will try to create a draft to see if this works. By the way, @jarrodparkes if you want to help with this, you are welcome 🙂
@4brunu I appreciate your efforts with this! However, I’m still too new to all of this to really be the judge of what makes a good solution. 😃