public 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 doLogin() / 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.
Fields
public static final String GOOGLE_ISSUER = "https://accounts.google.com" | Google’s well-known OIDC issuer. |
Methods
public static GoogleConnect getInstance() | Gets the GoogleConnect singleton instance . |
public boolean isNativeLoginSupported() | Returns true if this service supports native login. |
protected Oauth2 createOauth2() | Creates the oauth2 to be used to login in case no native login is available for this service. |
public AsyncResource<OidcTokens> signIn(String clientId, String redirectUri, String... scopes) | Modern Google sign-in. |
protected boolean validateToken(String token) | Returns true if the previous granted access token is still valid otherwise false. |
Inherited methods
Field details
GOOGLE_ISSUER
public static final String GOOGLE_ISSUER = "https://accounts.google.com"Method details
getInstance
public static GoogleConnect getInstance()Returns
isNativeLoginSupported
public boolean isNativeLoginSupported()Returns
createOauth2
protected Oauth2 createOauth2()Returns
signIn
public AsyncResource<OidcTokens> signIn(String clientId, String redirectUri, String... scopes)Parameters
clientIdString- 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.
redirectUriString- Redirect URI registered for that client. Custom
schemes (
com.example.app:/oauth2redirect) for mobile; HTTPS for web. scopesString...- OAuth scopes to request – include
openid email profileto get an ID token plus user metadata, plus any Google API scopes you need.
Returns
AsyncResource resolving to the OidcTokens for the signed-in
user.validateToken
protected boolean validateToken(String token)Parameters
tokenString- the access token to check