Reputation: 365
I'm trying to do an OAuth authorisation with an API in swift but I'm getting an error on my oauthswift.authorise call. I get the following error when I try to build it in Xcode.
Incorrect argument label in call (have 'withCallbackURL:success:failure:', expected 'deviceToken:success:failure:')
My code;
func authorise {
// create an instance and retain it
let oauthswift = OAuth2Swift(
consumerKey: "*******mykey*********",
consumerSecret: "*******mysecret*********",
authorizeUrl: "https://*****apiurl******/oauth/authorize",
accessTokenUrl: "https://*****apiurl******/oauth/access_token",
responseType: "token"
)
// authorize
let handle = oauthswift.authorize(
withCallbackURL: URL(string: "******myAppName*******://oauth-callback/success")!,
success: { credential, response, parameters in
print(credential.oauthToken)
print(credential.oauthTokenSecret)
print(parameters["user_id"])
// Do your request
},
failure: { error in
print(error.localizedDescription)
}
)
}
My understanding of this .authorise() function is that when the user has logged in and the Token and secret have been given the callback url will be called and it will pass the token and secret back to my app. Please let me know if i'm wrong!
Cheers for any help.
Will
Upvotes: 1
Views: 186
Reputation: 365
Turns out I was using OAuth2 instead of OAuth1... All solved now.
Upvotes: 1