public final class MicrosoftConnect

  1. Object
  2. Login
  3. MicrosoftConnect

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) { ... }
    });

Fields

public static final String COMMON_TENANT = "common"“common” – accepts personal, work, and school accounts.

Methods

public static synchronized MicrosoftConnect getInstance()
public MicrosoftConnect withTenant(String tenant)Picks the Entra ID tenant to target.
public String getTenant()
public boolean isNativeLoginSupported()Returns true if this service supports native login.
protected boolean validateToken(String token)Returns true if the previous granted access token is still valid otherwise false.
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.

Inherited methods

Field details

COMMON_TENANT

public static final String COMMON_TENANT = "common"
“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.

Method details

getInstance

public static synchronized 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()
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

validateToken

protected boolean validateToken(String token)
Returns true if the previous granted access token is still valid otherwise false.

Parameters

token String
the access token to check

Returns

true of the token is valid

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.