CredentialsGitHub
public class CredentialsGitHub : CredentialsPluginProtocol
Authentication using GitHub web login with OAuth. See GitHub manual for more information.
-
The URL that GitHub redirects back to.
Declaration
Swift
public var callbackUrl: String
-
The User-Agent to be passed along on GitHub API calls. User-Agent must be set in order to access GitHub API (i.e., to get user profile). See GitHub manual for more information.
Declaration
Swift
public private(set) var userAgent: String
-
The name of the plugin.
Declaration
Swift
public var name: String
-
An indication as to whether the plugin is redirecting or not.
Declaration
Swift
public var redirecting: Bool
-
User profile cache.
Declaration
Swift
public var usersCache: NSCache<NSString, BaseCacheElement>?
-
Initialize a
CredentialsGitHub
instance.Parameter
Parameter clientId: The Client ID of the app in the GitHub Developer applications.Parameter
Parameter clientSecret: The Client Secret of the app in the GitHub Developer applications.Parameter
Parameter callbackUrl: The URL that GitHub redirects back to.Declaration
Swift
public init (clientId: String, clientSecret: String, callbackUrl: String, userAgent: String?=nil)
Parameters
clientId
The Client ID of the app in the GitHub Developer applications.
clientSecret
The Client Secret of the app in the GitHub Developer applications.
callbackUrl
The URL that GitHub redirects back to.
-
Authenticate incoming request using GitHub web login with OAuth.
Parameter
Parameter request: TheRouterRequest
object used to get information about the request.Parameter
Parameter response: TheRouterResponse
object used to respond to the request.Parameter
Parameter options: The dictionary of plugin specific options.Parameter
Parameter onSuccess: The closure to invoke in the case of successful authentication.Parameter
Parameter onFailure: The closure to invoke in the case of an authentication failure.Parameter
Parameter onPass: The closure to invoke when the plugin doesn’t recognize the authentication data in the request.Parameter
Parameter inProgress: The closure to invoke to cause a redirect to the login page in the case of redirecting authentication.Declaration
Swift
public func authenticate (request: RouterRequest, response: RouterResponse, options: [String:Any], onSuccess: @escaping (UserProfile) -> Void, onFailure: @escaping (HTTPStatusCode?, [String:String]?) -> Void, onPass: @escaping (HTTPStatusCode?, [String:String]?) -> Void, inProgress: @escaping () -> Void)
Parameters
request
The
RouterRequest
object used to get information about the request.response
The
RouterResponse
object used to respond to the request.options
The dictionary of plugin specific options.
onSuccess
The closure to invoke in the case of successful authentication.
onFailure
The closure to invoke in the case of an authentication failure.
onPass
The closure to invoke when the plugin doesn’t recognize the authentication data in the request.
inProgress
The closure to invoke to cause a redirect to the login page in the case of redirecting authentication.