Class Login
- Direct Known Subclasses:
FacebookConnect, GoogleConnect
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds the given scopes to the OAuth2 login request.connect()Connects to the login service asynchronously, automatically logging in if not yet logged in.protected Oauth2Creates the oauth2 to be used to login in case no native login is available for this service.voiddoLogin()Logs in the user.voiddoLogin(LoginCallback callback) Initiates login using the given single-use callback.voiddoLogout()Logs out the current userThe AccessToken of this serviceabstract booleanReturns true if this service supports native login.booleanA flag used by the javascript port to indicate that the login will use a redirect for the prompt instead of a popup.booleanIndicates if the user is currently logged inbooleanIndicates if the user is currently logged in.voidLogs in the current user natively.voidLogs out the current user natively.voidsetAccessToken(AccessToken token) Sets the Login access tokenvoidSets the login callback that will receive event callback notification from the APIvoidsetClientId(String id) The client id (appid) which asks to connectvoidsetClientSecret(String secret) The client secretvoidsetOauth2URL(String oauth2URL) The oauth2 URLvoidsetPreferRedirectPrompt(boolean preferRedirectPrompt) A flag used by the javascript port to indicate that the login will use a redirect for the prompt instead of a popup.voidsetRedirectURI(String redirectURI) The redirect URIvoidThe authentication scopevoidThis method tries to validate the last access token if exists, if the last token is not valid anymore it will try to login the user in order to get a fresh token The method blocks until a valid token has been grantedprotected abstract booleanvalidateToken(String token) Returns true if the previous granted access token is still valid otherwise false.
-
Constructor Details
-
Login
public Login()
-
-
Method Details
-
addScopes
-
connect
Connects to the login service asynchronously, automatically logging in if not yet logged in.
Returns
AsyncResource that can be monitored for completion.
Since
7.0
-
doLogin
Initiates login using the given single-use callback.
Parameters
callback: Callback to be called if login succeeds or fails.
Since
7.0
-
doLogin
public void doLogin()Logs in the user. If the service has a native login it will try to use that, otherwise an Oauth2 web login will be used. -
doLogout
public void doLogout()Logs out the current user -
isUserLoggedIn
public boolean isUserLoggedIn()Indicates if the user is currently logged in
Returns
true if logged in
-
nativeIsLoggedIn
public boolean nativeIsLoggedIn()Indicates if the user is currently logged in. Subclasses that uses a native sdk to login/logout should override this method.
Returns
true if logged in
-
nativelogin
public void nativelogin()Logs in the current user natively. Subclasses that uses a native sdk to login/logout should override this method. -
nativeLogout
public void nativeLogout()Logs out the current user natively. Subclasses that uses a native sdk to login/logout should override this method. -
isNativeLoginSupported
public abstract boolean isNativeLoginSupported()Returns true if this service supports native login. If implementation returns true here, the nativelogin, nativelogout, nativeIsLoggedIn should be implemented
Returns
true if the service supports native login
-
getAccessToken
The AccessToken of this service
Returns
the token
-
setAccessToken
Sets the Login access token -
validateToken
This method tries to validate the last access token if exists, if the last token is not valid anymore it will try to login the user in order to get a fresh token The method blocks until a valid token has been granted- Throws:
IOException
-
validateToken
Returns true if the previous granted access token is still valid otherwise false.
Parameters
token: the access token to check
Returns
true of the token is valid
-
setCallback
Sets the login callback that will receive event callback notification from the API
Parameters
lc: @param lc the login callback or null to remove the existing login callback
-
setClientId
The client id (appid) which asks to connect
Parameters
clientId
-
setClientSecret
The client secret
Parameters
clientSecret
-
setRedirectURI
The redirect URI
Parameters
redirectURI
-
setScope
The authentication scope -
setOauth2URL
The oauth2 URL -
createOauth2
Creates the oauth2 to be used to login in case no native login is available for this service.
Returns
- Returns:
- the Oauth2 to be used to login if no native login available and on the simulator
-
isPreferRedirectPrompt
public boolean isPreferRedirectPrompt()A flag used by the javascript port to indicate that the login will use a redirect for the prompt instead of a popup. On the web, a redirect is usually better UX but it can be problematic since it involves leaving the app, and reloading it after the login.
Returns
the preferRedirectPrompt
Since
7.0
-
setPreferRedirectPrompt
public void setPreferRedirectPrompt(boolean preferRedirectPrompt) A flag used by the javascript port to indicate that the login will use a redirect for the prompt instead of a popup. On the web, a redirect is usually better UX but it can be problematic since it involves leaving the app, and reloading it after the login.
Parameters
preferRedirectPrompt: the preferRedirectPrompt to set
Since
7.0
-