Hi,
I am successfully authenticating from swift to Strava with p2/Oauth2 and requesting activities. I thought it would be nice to use the models out of the provided (thanks Strava) swagger spec. I've generated that code and added it to the project, and am absolutely unsuccessful in getting the SwaggerClientAPI to return anything other than errors. I'm getting 401's or 500's. I thought to add the oauth2.accessToken to the SwaggerClientAPI.customHeaders and maybe it would work, but does not.
ActivitiesAPI.getLoggedInAthleteActivities { activities, error in
debugPrint(activities as Any)
debugPrint(error as Any)
}
Everything is fine when
Clearly, the session manager from p2/Oauth2 is working.
I see in AlamofireImplementations.swift
open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
required public init(method: String, URLString: String, parameters: [String : Any]?, isBody: Bool, headers: [String : String] = [:]) {
super.init(method: method, URLString: URLString, parameters: parameters, isBody: isBody, headers: headers)
}
/**
May be overridden by a subclass if you want to control the session
configuration.
*/
open func createSessionManager() -> Alamofire.SessionManager {
let configuration = URLSessionConfiguration.default
configuration.httpAdditionalHeaders = buildHeaders()
return Alamofire.SessionManager(configuration: configuration)
}
// omitted
}
Should I be overriding the createSessionManager function to use the p2/oauth2 session manager?
What is everybody else doing in this situation?
Thanks!
T/O