I am moving my project from Swift 2.3 to Swift 3. And with difficulty, as expected.
Here is the function that is used for OAuth using OAuthSwift . I tried to convert
class func OAuthSwiftAuthorization(inViewController viewController: UIViewController, withOAuthInfo info:FitnessTracker, successHandler:@escaping MyOAuthNewSuccessHandler, failure: @escaping ((_ error: NSError) -> Void)) {
let oauthswift = OAuth2Swift(
consumerKey: info.consumerKey,
consumerSecret: info.consumerSecret,
authorizeUrl: info.authorizeUrl,
accessTokenUrl: info.accessTokenUrl,
responseType: info.responseType
)
oauthswift.authorizeURLHandler = SafariURLHandler(viewController: viewController, oauthSwift: oauthswift)
oauthswift.accessTokenBasicAuthentification = true
oauthswift.allowMissingStateCheck = true
oauthswift.authorize(withCallbackURL: URL(string: info.callBackUrl)!, scope: info.scope, state: info.state, success: { (credential, response, parameters) in
successHandler(credential, response, parameters)
}) { (error) in
failure(error: error)
print(error.localizedDescription)
}
}
But I get an error
oauthswift.authorize(withCallbackURL: URL(string: info.callBackUrl)!, scope: info.scope, state: info.state, success: { (credential, response, parameters) in
Error Status
Ambiguous reference to member authority (withCallbackURL: scope: state: parameters: headers: success: failure :) '
Here is the working code from Swift 2.
oauthswift.authorizeWithCallbackURL(
URL(string: info.callBackUrl)!,
scope: info.scope, state:info.state,
success: { credential, response, parameters in
successHandler(credientials: credential, response: response, params: parameters)
},
failure: { error in
failure(error: error)
print(error.localizedDescription)
}
)
UPDATE:
The error does not appear unitil. I print successful and uncontrollable characters. This corresponds to a fine:
oauthswift.authorize(withCallbackURL: URL(string: info.callBackUrl)!, scope: info.scope, state: info.state, success: { (credential, response, parameters) in
}) { (erorr) in
}
So please help me. Thanks.