 
     /**
     Convenient method to retrieve a Facebook oauth2 module.
-    
+
     :param: config a Facebook configuration object. See FacebookConfig.
-    
+
     :returns: a Facebook OAuth2 module.
     */
     public class func addFacebookAccount(config: FacebookConfig) -> FacebookOAuth2Module {
         return addAccount(config, moduleClass: FacebookOAuth2Module.self) as! FacebookOAuth2Module
     }
-    
+
     /**
     Convenient method to retrieve a Google oauth2 module ready to be used.
-    
+
     :param: config a google configuration object. See GoogleConfig.
-    
+
     :returns: a google OAuth2 module.
     */
     public class func addGoogleAccount(config: GoogleConfig) -> OAuth2Module {
         return addAccount(config, moduleClass: OAuth2Module.self)
     }
-    
+
     /**
     Convenient method to retrieve a Keycloak oauth2 module ready to be used.
-    
+
     :param: config a Keycloak configuration object. See KeycloakConfig.
-    
+
     :returns: a Keycloak OAuth2 module.
     */
     public class func addKeycloakAccount(config: KeycloakConfig) -> KeycloakOAuth2Module {

    public init(clientId: String, scopes: [String], accountId: String? = nil, isOpenIDConnect: Bool = false) {
        let bundleString = NSBundle.mainBundle().bundleIdentifier ?? "google"
        super.init(base: "https://accounts.google.com",
            authzEndpoint: "o/oauth2/auth",
            redirectURL: "\(bundleString):/oauth2Callback",
            accessTokenEndpoint: "o/oauth2/token",
            clientId: clientId,
            refreshTokenEndpoint: "o/oauth2/token",
            revokeTokenEndpoint: "rest/revoke",
            isOpenIDConnect: isOpenIDConnect,
            userInfoEndpoint: isOpenIDConnect ? "https://www.googleapis.com/plus/v1/people/me/openIdConnect" : nil,
            scopes: scopes,

public class AccountManager {
    /// List of OAuth2 modules available for a given app. Each module is linked to an OAuht2Session which securely store the tokens.
    var modules: [String: OAuth2Module]

    init() {
        self.modules = [String: OAuth2Module]()
    }

    /// access a shared instance of an account manager
    public class var sharedInstance: AccountManager {
        struct Singleton {
