Skip to content

Instantly share code, notes, and snippets.

@danshev
Last active August 29, 2015 14:17
Show Gist options
  • Save danshev/8a81b82636b89b1a4f65 to your computer and use it in GitHub Desktop.
Save danshev/8a81b82636b89b1a4f65 to your computer and use it in GitHub Desktop.
import Oauth2
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
println("viewDidLoad")
let settings = ["client_id": "abcde",
"client_secret": "12345",
"authorize_uri": "https://www.linkedin.com/uas/oauth2/authorization",
"token_uri": "https://www.linkedin.com/uas/oauth2/accessToken",
"scope": "r_basicprofile",
"redirect_uris": ["myapp://oauth/callback"], // don't forget to register this scheme
]
let oauth = OAuth2CodeGrant(settings: settings)
oauth.viewTitle = "Title" // optional
oauth.onAuthorize = { parameters in
println("Did authorize with parameters: \(parameters)")
}
oauth.onFailure = { error in // `error` is nil on cancel
if nil != error {
println("Authorization went wrong: \(error!.localizedDescription)")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment