public final class 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
From Login
addScopes, connect, doLogin, doLogin, doLogout, isUserLoggedIn, nativeIsLoggedIn, nativelogin, nativeLogout, getAccessToken, setAccessToken, validateToken, setCallback, setClientId, setClientSecret, setRedirectURI, setScope, setOauth2URL, createOauth2, isPreferRedirectPrompt, setPreferRedirectPrompt
Field details
COMMON_TENANT
public static final String COMMON_TENANT = "common"Method details
getInstance
public static synchronized MicrosoftConnect getInstance()withTenant
public MicrosoftConnect withTenant(String tenant)COMMON_TENANT,
"organizations", "consumers", or a tenant GUID / verified domain
(e.g. "contoso.onmicrosoft.com").getTenant
public String getTenant()isNativeLoginSupported
public boolean isNativeLoginSupported()Returns
validateToken
protected boolean validateToken(String token)Parameters
tokenString- the access token to check
Returns
signIn
public AsyncResource<OidcTokens> signIn(String clientId, String redirectUri, String... scopes)