# Class GoogleConnect

java.lang.Object
com.codename1.social.Login
com.codename1.social.GoogleConnect

public class GoogleConnect extends Login

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
  Modifier and Type
  Field
  Description
  `static final String`
  `GOOGLE_ISSUER`
  Google's well-known OIDC issuer.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected Oauth2`
  `createOauth2()`
  Creates the oauth2 to be used to login in case no native login is available for this service.
  `static GoogleConnect`
  `getInstance()`
  Gets the GoogleConnect singleton instance .
  `boolean`
  `isNativeLoginSupported()`
  Returns true if this service supports native login.
  `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.

  ### 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`

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### GOOGLE_ISSUER

    public static final String GOOGLE_ISSUER
    Google's well-known OIDC issuer.
    See Also:
      - Constant Field Values

- ## Method Details

  - ### getInstance

    public static GoogleConnect getInstance()

    Gets the GoogleConnect singleton instance .

    ###### Returns

    the GoogleConnect instance

  - ### isNativeLoginSupported

    public boolean isNativeLoginSupported()
    Description copied from class: `Login`

    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

    Specified by:
      `isNativeLoginSupported` in class `Login`

  - ### createOauth2

    protected Oauth2 createOauth2()
    Description copied from class: `Login`

    Creates the oauth2 to be used to login in case no native login is available for this service.

    ###### Returns

    Overrides:
      `createOauth2` in class `Login`
    Returns:
      the Oauth2 to be used to login if no native login available and on the simulator

  - ### signIn

    public AsyncResource<OidcTokens> signIn(String clientId, String redirectUri, String... scopes)

    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 -- include `openid email profile` to get an ID token plus user metadata, plus any Google API scopes you need.

    ###### Returns

    An `AsyncResource` resolving to the `OidcTokens` for the signed-in user.

  - ### validateToken

    protected boolean validateToken(String token)
    Description copied from class: `Login`

    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

    Specified by:
      `validateToken` in class `Login`