Closed muhdmirzamz closed 6 years ago
Hey, that's strange. Could you provide me with some code that you use?
Thanks for getting back and sorry for the late reply!
Here's my code. Do note this follows the Swift 3 syntax so some of the documentation code is a little different here.
My main view controller
var config = (UIApplication.shared.delegate as! AppDelegate).config
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
var clientId = "<client_id>"
var clientSecret = "<client_secret>"
self.config = OAuthConfiguration.init(token: clientId, secret: clientSecret, scopes: ["repo", "read:org"])
let url = config?.authenticate()
UIApplication.shared.open(url!, options: [:], completionHandler: nil)
}
My AppDelegate
var config: OAuthConfiguration?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
self.config?.handleOpenURL(url: url, completion: { (token) in
Octokit(token).me() { response in
switch response {
case .success(let user):
print("User login: \(user.login)")
case .failure(let error):
print("Error: \(error)")
}
}
})
return false
}
Hey, just an FYI. I managed to figure out the issue. I just put the code from my main view controller to my appdelegate's
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
}
function. All good now!
Alright, glad you solved it. Sorry I didn't have the time to investigate.
Would you like me to provide an updated example code snippet for Swift 3 or update the existing README or documentations?
Yes please, that would be very helpful.
Okay, it's done in pull request #64 👍
Hi,
Big fan of this project. One problem though, I have tried the OAuth config settings and gotten the
code
attribute. I followed the code example you provided in theREADME.md
but printing outuser.login
does not work. Mind helping me out here?