Skip to content

Commit

Permalink
Merge pull request #12 from munkius/master
Browse files Browse the repository at this point in the history
Added possibility to add custom params
  • Loading branch information
Dongri Jin committed Dec 15, 2014
2 parents df8fe80 + f73c573 commit b9647f5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion OAuthSwift/OAuth2Swift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class OAuth2Swift {
typealias TokenSuccessHandler = (credential: OAuthSwiftCredential, response: NSURLResponse?) -> Void
typealias FailureHandler = (error: NSError) -> Void

func authorizeWithCallbackURL(callbackURL: NSURL, scope: String, state: String, success: TokenSuccessHandler, failure: ((error: NSError) -> Void)) {

func authorizeWithCallbackURL(callbackURL: NSURL, scope: String, state: String, params: Dictionary<String, String> = Dictionary<String, String>(), success: TokenSuccessHandler, failure: ((error: NSError) -> Void)) {
self.observer = NSNotificationCenter.defaultCenter().addObserverForName(CallbackNotification.notificationName, object: nil, queue: NSOperationQueue.mainQueue(), usingBlock:{
notification in
NSNotificationCenter.defaultCenter().removeObserver(self.observer!)
Expand Down Expand Up @@ -83,6 +84,11 @@ class OAuth2Swift {
if (state != "") {
urlString += "&state=\(state)"
}

for param in params {
urlString += "&\(param.0)=\(param.1)"
}

let queryURL = NSURL(string: urlString)
UIApplication.sharedApplication().openURL(queryURL!)
}
Expand Down

0 comments on commit b9647f5

Please sign in to comment.