Skip to content

Commit

Permalink
add blockForCallbackURLQueryParams to oauth2 providers
Browse files Browse the repository at this point in the history
  • Loading branch information
noppoMan committed Aug 31, 2017
1 parent 9d7c5e5 commit be6f112
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public struct FacebookAuthorizationProvider: OAuth2AuthorizationProvidable {

public let callback: RespodWithCredential

public init(path: String, consumerKey: String, consumerSecret: String, callbackURL: CallbackURL, scope: String, callback: @escaping RespodWithCredential) {
public init(path: String, consumerKey: String, consumerSecret: String, callbackURL: CallbackURL, blockForCallbackURLQueryParams: ((Request) -> [URLQueryItem])? = nil, scope: String, callback: @escaping RespodWithCredential) {
self.path = path

self.oauth = OAuth2(
Expand All @@ -30,6 +30,7 @@ public struct FacebookAuthorizationProvider: OAuth2AuthorizationProvidable {
authorizeURL: "https://www.facebook.com/dialog/oauth",
accessTokenURL: "https://graph.facebook.com/oauth/access_token",
callbackURL: callbackURL,
blockForCallbackURLQueryParams: blockForCallbackURLQueryParams,
scope: scope
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public struct GithubAuthorizationProvider: OAuth2AuthorizationProvidable {

public let callback: RespodWithCredential

public init(path: String, consumerKey: String, consumerSecret: String, callbackURL: CallbackURL, scope: String, callback: @escaping RespodWithCredential) {
public init(path: String, consumerKey: String, consumerSecret: String, callbackURL: CallbackURL, blockForCallbackURLQueryParams: ((Request) -> [URLQueryItem])? = nil, scope: String, callback: @escaping RespodWithCredential) {
self.path = path

self.oauth = OAuth2(
Expand All @@ -30,6 +30,7 @@ public struct GithubAuthorizationProvider: OAuth2AuthorizationProvidable {
authorizeURL: "http://github.com/login/oauth/authorize",
accessTokenURL: "https://github.com/login/oauth/access_token",
callbackURL: callbackURL,
blockForCallbackURLQueryParams: blockForCallbackURLQueryParams,
scope: scope
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public struct GoogleAuthorizationProvider: OAuth2AuthorizationProvidable {

public let callback: RespodWithCredential

public init(path: String, consumerKey: String, consumerSecret: String, callbackURL: CallbackURL, scope: String, callback: @escaping RespodWithCredential) {
public init(path: String, consumerKey: String, consumerSecret: String, callbackURL: CallbackURL, blockForCallbackURLQueryParams: ((Request) -> [URLQueryItem])? = nil, scope: String, callback: @escaping RespodWithCredential) {
self.path = path

self.oauth = OAuth2(
Expand All @@ -26,6 +26,7 @@ public struct GoogleAuthorizationProvider: OAuth2AuthorizationProvidable {
authorizeURL: "https://accounts.google.com/o/oauth2/auth",
accessTokenURL: "https://accounts.google.com/o/oauth2/token",
callbackURL: callbackURL,
blockForCallbackURLQueryParams: blockForCallbackURLQueryParams,
scope: scope
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public struct InstagramAuthorizationProvider: OAuth2AuthorizationProvidable {

public let callback: RespodWithCredential

public init(path: String, consumerKey: String, consumerSecret: String, callbackURL: CallbackURL, scope: String, callback: @escaping RespodWithCredential) {
public init(path: String, consumerKey: String, consumerSecret: String, callbackURL: CallbackURL, blockForCallbackURLQueryParams: ((Request) -> [URLQueryItem])? = nil, scope: String, callback: @escaping RespodWithCredential) {
self.path = path

self.oauth = OAuth2(
Expand All @@ -26,6 +26,7 @@ public struct InstagramAuthorizationProvider: OAuth2AuthorizationProvidable {
authorizeURL: "https://api.instagram.com/oauth/authorize",
accessTokenURL: "https://api.instagram.com/oauth/access_token",
callbackURL: callbackURL,
blockForCallbackURLQueryParams: blockForCallbackURLQueryParams,
scope: scope
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public protocol OAuth2AuthorizationProvidable {
var path: String { get }
var oauth: OAuth2 { get }
var callback: RespodWithCredential { get }
init(path: String, consumerKey: String, consumerSecret: String, callbackURL: CallbackURL, scope: String, callback: @escaping RespodWithCredential)
init(path: String, consumerKey: String, consumerSecret: String, callbackURL: CallbackURL, blockForCallbackURLQueryParams: ((Request) -> [URLQueryItem])?, scope: String, callback: @escaping RespodWithCredential)
func getAccessToken(for: Request) throws -> Credential
func authorize(for: Request) throws -> (Credential, LoginUser)
}
Expand Down

0 comments on commit be6f112

Please sign in to comment.