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) { ... }
});
- Since:
- 7.0.245
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String"common" -- accepts personal, work, and school accounts. -
Method Summary
Modifier and TypeMethodDescriptionstatic MicrosoftConnectbooleanReturns true if this service supports native login.Drives a full authorization-code-with-PKCE sign-in through the system browser and resolves with the issued tokens.protected booleanvalidateToken(String token) Returns true if the previous granted access token is still valid otherwise false.withTenant(String tenant) Picks the Entra ID tenant to target.Methods inherited from class Login
addScopes, connect, createOauth2, doLogin, doLogin, doLogout, getAccessToken, isPreferRedirectPrompt, isUserLoggedIn, nativeIsLoggedIn, nativelogin, nativeLogout, setAccessToken, setCallback, setClientId, setClientSecret, setOauth2URL, setPreferRedirectPrompt, setRedirectURI, setScope, validateToken
-
Field Details
-
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
-
withTenant
Picks the Entra ID tenant to target. PassCOMMON_TENANT,"organizations","consumers", or a tenant GUID / verified domain (e.g."contoso.onmicrosoft.com"). -
getTenant
-
isNativeLoginSupported
public boolean isNativeLoginSupported()Description copied from class:LoginReturns 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:
isNativeLoginSupportedin classLogin
-
validateToken
Description copied from class:LoginReturns 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:
validateTokenin classLogin
-
signIn
Drives a full authorization-code-with-PKCE sign-in through the system browser and resolves with the issued tokens.
-