Class GoogleConnect
Sign-in-with-Google for Codename One.
As of 2025 Google replaced the legacy Sign-In SDK with the Google Identity
Services (GIS) family of APIs. GIS encourages the OAuth 2.0 authorization
code flow with PKCE driven from the system browser -- exactly what
OidcClient does. New apps should call
[#signIn(String, String, String[])] which goes through that modern path
and works on every Codename One platform without a native SDK dependency.
The older Login.doLogin() / Login.nativelogin() path remains for source
compatibility, and on iOS / Android it still delegates to the native
implementation provided by the port (see Ports/iOSPort and
Ports/Android). On other platforms the legacy path also now goes
through OidcClient instead of the deprecated Oauth2 in-app WebView.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionprotected Oauth2Creates the oauth2 to be used to login in case no native login is available for this service.static GoogleConnectGets the GoogleConnect singleton instance .booleanReturns true if this service supports native login.Modern Google sign-in.protected booleanvalidateToken(String token) Returns true if the previous granted access token is still valid otherwise false.Methods inherited from class Login
addScopes, connect, doLogin, doLogin, doLogout, getAccessToken, isPreferRedirectPrompt, isUserLoggedIn, nativeIsLoggedIn, nativelogin, nativeLogout, setAccessToken, setCallback, setClientId, setClientSecret, setOauth2URL, setPreferRedirectPrompt, setRedirectURI, setScope, validateToken
-
Field Details
-
GOOGLE_ISSUER
-
-
Method Details
-
getInstance
Gets the GoogleConnect singleton instance .
Returns
the GoogleConnect instance
-
isNativeLoginSupported
public boolean isNativeLoginSupported()Description copied from class:LoginReturns 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
- Specified by:
isNativeLoginSupportedin classLogin
-
createOauth2
Description copied from class:LoginCreates the oauth2 to be used to login in case no native login is available for this service.
Returns
- Overrides:
createOauth2in classLogin- Returns:
- the Oauth2 to be used to login if no native login available and on the simulator
-
signIn
Modern Google sign-in. Goes through the Google Identity Services OIDC endpoints with PKCE, using the system browser. Works the same on every platform (iOS, Android, JavaSE, Web) provided the platform port wires the system browser native interface; otherwise it falls back to an in-app browser window.
Parameters
clientId: OAuth 2.0 client ID issued in Google Cloud Console. Use the iOS / Android client for the matching native build, or the Web client when running in the simulator / web port.redirectUri: Redirect URI registered for that client. Custom schemes (com.example.app:/oauth2redirect) for mobile; HTTPS for web.scopes: OAuth scopes to request -- includeopenid email profileto get an ID token plus user metadata, plus any Google API scopes you need.
Returns
An
AsyncResourceresolving to theOidcTokensfor the signed-in user.Since
8.0
-
validateToken
Description copied from class:LoginReturns 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
- Specified by:
validateTokenin classLogin
-