This return is sending back a single string, the accessToken from the ContentResponse:
return body.encodeResponse(for: request)
.map { $0.body.buffer }
.flatMap { buffer in
return request.client.post(url, headers: self.callbackHeaders) { $0.body = buffer }
}.flatMapThrowing { response in
return try response.content.get(ContentResponse.self)
}.map { $0.accessToken }
which is being received in the completion handler here:
return try self.fetchToken(from: request).flatMap { accessToken in
How can I send back two strings - both the accessToken and the refreshToken from the ContentResponse?
Thanks so much for any help in how to structure this!
You could define and use a
structto return, but for one-off cases like this, I usually just go with a tuple with named members:That will result in a return type of
[(accessToken: String, refreshToken: String)]instead of[String], so the return type offetchToken(from:)will have to be changed to match.Then the code where you call it looks like this: