Class MicrosoftConnect

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

public final class MicrosoftConnect extends Login

Sign-in with a Microsoft account (personal, work, or school) backed by Microsoft Entra ID (formerly Azure Active Directory). Wraps OidcClient against Microsoft's v2.0/.well-known/openid-configuration endpoint.

On iOS and Android, where Microsoft ships the MSAL SDK with broker integration (Microsoft Authenticator, Company Portal), this class still uses the system browser flow -- MSAL's broker is only available when the app embeds the native MSAL SDK and is configured for the conditional access scenarios that require it. For 95% of Codename One apps the system-browser flow is the right answer, and lets the same code work in the simulator and on the web port.

MicrosoftConnect.getInstance()
    .withTenant("common")             // or your tenant GUID
    .signIn(
        "YOUR_CLIENT_ID",
        "com.example.app:/oauth2redirect",
        "openid", "email", "profile", "User.Read")
    .ready(new SuccessCallback<OidcTokens>() {
        public void onSucess(OidcTokens t) { ... }
    });
Since:
8.0
  • Field Details

    • COMMON_TENANT

      public static final String COMMON_TENANT
      "common" -- accepts personal, work, and school accounts. Use this for most multi-tenant apps. Pass a tenant GUID to restrict to a single Entra ID tenant; pass "organizations" for work/school only; "consumers" for personal only.
      See Also:
  • Method Details

    • getInstance

      public static MicrosoftConnect getInstance()
    • withTenant

      public MicrosoftConnect withTenant(String tenant)
      Picks the Entra ID tenant to target. Pass COMMON_TENANT, "organizations", "consumers", or a tenant GUID / verified domain (e.g. "contoso.onmicrosoft.com").
    • getTenant

      public String getTenant()
    • 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
    • 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
    • signIn

      public AsyncResource<OidcTokens> signIn(String clientId, String redirectUri, String... scopes)
      Drives a full authorization-code-with-PKCE sign-in through the system browser and resolves with the issued tokens.