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 { get }
  • The name of the plugin.

    Declaration

    Swift

    public let name: String
  • An indication as to whether the plugin is redirecting or not.

    Declaration

    Swift

    public let redirecting: Bool
  • User profile cache.

    Declaration

    Swift

    public var usersCache: NSCache<NSString, BaseCacheElement>?
  • A delegate for UserProfile manipulation.

    Declaration

    Swift

    public let userProfileDelegate: UserProfileDelegate?
  • Initialize a CredentialsGitHub instance.

    Declaration

    Swift

    public init(clientId: String, clientSecret: String, callbackUrl: String, userAgent: String? = nil, options: [String : Any] = [:])

    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.

    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.