You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When you call a service with Bearer auth like JWT and the token was revoked or something made the token no longer valid, e.g., a user password change, the service can return a 401, and no Body / no error with the response. This scenario will not call the retry because "if let response, let error" will fail. The reason is that error is nil and skip over the interceptor.retry call.
case let .success(modifiedRequest):
let dataTask = urlSession.dataTaskFromProtocol(with: modifiedRequest) { data, response, error in
self.cleanupRequest()
if let response, let error {
self.openAPIClient.interceptor.retry(urlRequest: modifiedRequest, urlSession: urlSession, requestBuilder: self, data: data, response: response, error: error) { retry in
switch retry {
case .retry:
self.execute(completion: completion)
case .dontRetry:
self.openAPIClient.apiResponseQueue.async {
self.processRequestResponse(urlRequest: request, data: data, response: response, error: error, completion: completion)
}
}
}
} else {
self.openAPIClient.apiResponseQueue.async {
self.processRequestResponse(urlRequest: request, data: data, response: response, error: error, completion: completion)
}
}
}
Generate the openapi code and add it to a project authenticate with Bearer auth like JWT. Once the app has a valid JWT invalidate the token server side. so that the server returns a 401 with no error / no body and it won't call the interceptor.retry
Inside URLSessionImplementations.swift " if let response, let error {" remove the requirement for error to have a value.
Error is not required it is the HTTP status code that determines what action should be taken. However, I am not sure why a 401 with no body does not return an error from urlSession.dataTaskFromProtocol
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
When you call a service with Bearer auth like JWT and the token was revoked or something made the token no longer valid, e.g., a user password change, the service can return a 401, and no Body / no error with the response. This scenario will not call the retry because "if let response, let error" will fail. The reason is that error is nil and skip over the interceptor.retry call.
openapi-generator version
7.10.0-SNAPSHOT
Commit SHA 266193f
OpenAPI declaration file content or url
I am not allowed to share this: Sorry
-->
Generation Details
java -jar openapi-generator-cli.jar generate -i swagger.json -g swift6 -o . -p projectName=******OpenApiClient -p podVersion=$3
-p sortModelPropertiesByRequiredFlag=true
-p hashableModels=false
-p removeMigrationProjectNameClass=true
-p enumUnknownDefaultCase=true
-p podSource=************openapiclient.git
-p podHomepage=*************openapiclient
-p podDocumentationURL=*************openapiclient/-/blob/master/README.md
-p podSwiftVersion=6.0
Steps to reproduce
Generate the openapi code and add it to a project authenticate with Bearer auth like JWT. Once the app has a valid JWT invalidate the token server side. so that the server returns a 401 with no error / no body and it won't call the interceptor.retry
The raw response from the service is with no Body
Related issues/PRs
I could not find any
Suggest a fix
Inside URLSessionImplementations.swift " if let response, let error {" remove the requirement for error to have a value.
Error is not required it is the HTTP status code that determines what action should be taken. However, I am not sure why a 401 with no body does not return an error from urlSession.dataTaskFromProtocol
The text was updated successfully, but these errors were encountered: