Created
November 24, 2014 06:45
-
-
Save ivan3bx/70e26e6b57e808a1b86c to your computer and use it in GitHub Desktop.
NXOAuth2 handler using AppleScript to open Safari
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func createAuthHandler() -> NXOAuth2PreparedAuthorizationURLHandler { | |
return { (url: NSURL!) -> Void in | |
let sourceScript = "tell application \"Safari\"\n" | |
+ " open location \"\(url.absoluteString!)\"\n" | |
+ " activate\n" | |
+ "end tell\n" | |
var err : NSDictionary? | |
let script = NSAppleScript(source: sourceScript)! | |
if script.compileAndReturnError(&err) { | |
if script.executeAndReturnError(&err) != nil { | |
// | |
// Success | |
// | |
} else { | |
println("Failed to execute and return") | |
} | |
} else { | |
println("Failed to compile script") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment