[GH-ISSUE #146] Use of unresolved identifier 'failureHandler' #88

Closed
opened 2026-03-03 16:45:35 +03:00 by kerem · 2 comments
Owner

Originally created by @FridaySG on GitHub (Nov 12, 2015).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/146

Beginner coder here, not sure what I've done wrong but Xcode is shouting at me from this line:

oauthswift.authorizeWithCallbackURL( NSURL(string: "http://google.com"), scope: "basic", state:"INSTAGRAM", success: {
credential, response, parameters in
println(credential.oauth_token)
}, failure: failureHandler)

Error is as title states, "unresolved identifier". Obviously because failureHandler was never declared but declaring shoots out even more errors. Thanks for any advice in advance.

Originally created by @FridaySG on GitHub (Nov 12, 2015). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/146 Beginner coder here, not sure what I've done wrong but Xcode is shouting at me from this line: oauthswift.authorizeWithCallbackURL( NSURL(string: "http://google.com"), scope: "basic", state:"INSTAGRAM", success: { credential, response, parameters in println(credential.oauth_token) }, failure: failureHandler) Error is as title states, "unresolved identifier". Obviously because failureHandler was never declared but declaring shoots out even more errors. Thanks for any advice in advance.
kerem 2026-03-03 16:45:35 +03:00
Author
Owner

@phimage commented on GitHub (Nov 12, 2015):

"unresolved identifier" means not defined...
I see, you copy readme code
Go to demo to have real code
https://github.com/dongri/OAuthSwift/blob/master/OAuthSwiftDemo/ViewController.swift

oauthswift.authorizeWithCallbackURL( NSURL(string: "http://google.com"), scope: "basic", state:"INSTAGRAM", success: {
credential, response, parameters in
println(credential.oauth_token)
},  failure: {(error:NSError!) -> Void in
            print(error.localizedDescription)
})

state:"INSTAGRAM"is for instagram
you can generate string like that

        let state: String = generateStateWithLength(20) as String

Then http://google.com is not a valid callback url, it must be an url that you must handle by url scheme (see readme and the scheme must be yourapplicationname://) or by implementing a webview and its delegate - in final OAuth2Swift.handleOpenURL(url) must be call

<!-- gh-comment-id:156064286 --> @phimage commented on GitHub (Nov 12, 2015): "unresolved identifier" means not defined... I see, you copy readme code Go to demo to have real code https://github.com/dongri/OAuthSwift/blob/master/OAuthSwiftDemo/ViewController.swift ``` swift oauthswift.authorizeWithCallbackURL( NSURL(string: "http://google.com"), scope: "basic", state:"INSTAGRAM", success: { credential, response, parameters in println(credential.oauth_token) }, failure: {(error:NSError!) -> Void in print(error.localizedDescription) }) ``` `state:"INSTAGRAM"`is for instagram you can generate string like that ``` swift let state: String = generateStateWithLength(20) as String ``` Then http://google.com is not a valid callback url, it must be an url that you must handle by url scheme (see readme and the scheme must be yourapplicationname://) or by implementing a webview and its delegate - in final `OAuth2Swift.handleOpenURL(url)` must be call
Author
Owner

@FridaySG commented on GitHub (Nov 12, 2015):

You got it man. Thank you very much for your support. Much appreciated.

<!-- gh-comment-id:156245430 --> @FridaySG commented on GitHub (Nov 12, 2015): You got it man. Thank you very much for your support. Much appreciated.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/OAuthSwift#88
No description provided.