CredentialsGoogle

public class CredentialsGoogle : CredentialsPluginProtocol

Authentication using Google web login with OAuth. See Google’s manual for more information.

  • A delegate for UserProfile manipulation.

    Declaration

    Swift

    public var userProfileDelegate: UserProfileDelegate? { get }
  • The URL that Google redirects back to.

    Declaration

    Swift

    public var callbackUrl: String
  • The name of the plugin.

    Declaration

    Swift

    public var name: String { get }
  • An indication as to whether the plugin is redirecting or not.

    Declaration

    Swift

    public var redirecting: Bool { get }
  • User profile cache.

    Declaration

    Swift

    public var usersCache: NSCache<NSString, BaseCacheElement>?
  • Initialize a CredentialsGoogle instance.

    Declaration

    Swift

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

    Parameters

    clientId

    The Client ID in the Google Developer’s console.

    clientSecret

    The Client Secret in the Google Developer’s console.

    callbackUrl

    The URL that Google redirects back to.

    options

    A dictionary of plugin specific options. The keys are defined in CredentialsGoogleOptions.

  • Authenticate incoming request using Google 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.