Advantech

Developer guide (advanced)

For engineers integrating Advantech sign-in into an existing system or going to production: the architecture, what to configure, every library and API this site provides, and what you must build yourself.

Architecture and responsibilities

The SSO handles signing in, but “who is signed in” is decided by your site's own session. The Client Secret lives only on your backend.

PartWhereResponsible for
BrowserThe user's computerShows the sign-in page / button / user badge (advantech-sso.js); only calls your site's /auth/* and never holds a secret.
Your backendYour serverKeeps the Client Secret, handles /auth/login and /auth/callback, creates and checks its own session, protects pages and APIs.
Advantech SSOhttps://ae-sso.advantech.comMicrosoft sign-in, single sign-on across services, allow / deny lists, user data and photos, sign-in log.
Microsoft Entra IDlogin.microsoftonline.comPasswords, MFA, Conditional Access. Your site never talks to it directly.

Sign-in in 7 steps

  1. The user opens your siteBrowser

    Your site sees they are not signed in yet.

  2. Send the user to the SSOYour backend

    Your backend (/auth/login) redirects the browser to the SSO with a random check value (state).

  3. Find out who they areSSOMicrosoft

    The SSO checks whether they are already signed in; only if not, Microsoft asks for their work account and password.

  4. Send the user back to your siteSSO

    The SSO redirects the browser to /auth/callback with a one-time “ticket” (code) and the same check value.

  5. Exchange the ticket for the user's dataYour backend

    Your backend checks the check value, then trades “ticket + Client Secret” with the SSO for name, email, department and more. The browser never sees this step, so the secret stays safe.

  6. Remember that they are signed inYour backend

    Your backend keeps the user in its own session. Every later request just checks the session — no need to ask the SSO again.

  7. The page shows the name and photoBrowser

    advantech-sso.js calls your /auth/me to get the current user and displays it.

What the user actually sees: open the site → (the first time) the Microsoft sign-in screen → back on the site. Everything else happens automatically in milliseconds.

What to set up

On the SSO (done by an SSO administrator or service owner)

ItemNeedWhat it does
Add a serviceRequiredGives the Client ID and Client Secret. Service owners can request one under “My services”.
Redirect URIRequiredRegister every address you use, production and local testing separately, e.g. https://myapp.advantech.world/auth/callback and http://localhost:5000/auth/callback. They must match exactly.
Data this service may readRecommendedAllow only the fields the site really needs (e.g. department, manager). Team members and raw data are off by default.
Data maskingOptionalAdministrators can cover some fields of some people with * (e.g. executives' mobile numbers). The field stays; every person carries masked and masked_fields for your code, and the front-end kit marks masked values as hidden automatically. A signed-in person always sees their own data unmasked.
Allowlist (permit) / Denylist (block)OptionalLimit which accounts or domains may sign in; refused users never reach your site.
People & Groups API devicesOptionalOnly if a server must look users up with nobody signed in (batch jobs, sync); turned on and registered by a super administrator.

On your server

ItemNeedWhat it does
SSO_CLIENT_ID
SSO_CLIENT_SECRET
RequiredFrom the SSO. Keep the secret in environment variables or a secret store — never in code, HTML or Git.
APP_URLRequiredYour site's public address (scheme + host + port), used to build the Redirect URI. Users must open the site with exactly this address.
FLASK_SECRET_KEY / SESSION_SECRETRequiredKey that signs the session cookie: 32+ bytes and fixed. Changing it on every restart signs everyone out and causes error=state.
HTTPSRequiredProduction must use https so the session cookie can be Secure. Plain http is allowed only for http://localhost.
Session storageRecommendedThe Node / Go starters keep sessions in memory: lost on restart and not shared between servers. Use Redis or a database in production.
Cookie settingsRecommendedHttpOnly, Secure (https), SameSite=Lax. Not SameSite=Strict — the cookie would be missing when the SSO redirects back.
Outbound accessRequiredYour backend must reach https://ae-sso.advantech.com over https (for /token and /userinfo).
Content-Security-PolicyOptionalWith a CSP: add https://ae-sso.advantech.com to script-src / style-src (or host the files yourself) and to img-src for photos.
Time sync (NTP)OptionalFor the People & Groups API: device-signed JWTs are short-lived, so the server clock must be within a minute.
# .env (never commit this file)
SSO_CLIENT_ID=svc_xxxxxxxx
SSO_CLIENT_SECRET=xxxxxxxx
APP_URL=https://myapp.advantech.world
SESSION_SECRET=<64 random characters: openssl rand -hex 32>

Libraries and APIs you can use

Reference these by URL or download them to your own site. The URLs are stable and will not be renamed.

Front end (HTML / CSS / JS)

FileURLWhat it does
advantech-sso.jshttps://ae-sso.advantech.com/assets/js/advantech-sso.js Download Sign-in button, user badge, field display, automatic redirect when signed out, multiple languages. No dependencies, about 10 KB.
advantech-sso.csshttps://ae-sso.advantech.com/assets/css/advantech-sso.css Download Styles for the sign-in page, button and badge. Every class starts with adv-sso- so your styles are untouched.
logo.svghttps://ae-sso.advantech.com/static/logo.svg Download Advantech logo (white on blue).
login.htmlhttps://ae-sso.advantech.com/developers/files/login.html Download Complete sign-in page template.
index.htmlhttps://ae-sso.advantech.com/developers/files/index.html Download Protected page template (name, department, photo).

In production consider hosting the JS / CSS yourself so SSO maintenance never affects your pages; referencing them directly always gives the latest version.

Backend samples

LanguageFileFull starter
Python / Flaskflask_app.py Download .zip
Node.js / Expressexpress_app.mjs Download .zip
PHPsso.php Download .zip
C# / ASP.NET CoreProgram.cs Download .zip
Java / Spring BootSsoController.java Download .zip
Gomain.go Download .zip

The backend needs no SSO-specific package — only each language's standard HTTP and session features (Flask, Express, PHP curl, ASP.NET Core, Spring Boot, Go standard library).

SSO APIs

APICalled byAuthenticationWhat it does
GET /authorizeBrowser—Parameters: client_id, redirect_uri (must exactly match the one registered), response_type=code, state (use a random value and compare it on return) prompt →
POST /tokenYour backendClient ID + SecretForm parameters: grant_type=authorization_code, code, redirect_uri, client_id, client_secret (HTTP Basic also works). A code is single-use and valid for 60 seconds.
GET /userinfoYour backendBearer access_tokenSend Authorization: Bearer <access_token> to get the user data. Access tokens last 1 hour.
GET /userinfo/photoYour backendBearer access_tokenThe user's photo (the service also needs the "photo" field).
GET /photo/{token}BrowserSigned URL (7 days)Photo URL for <img src> (absent when the user has no photo)
GET /logoutBrowser—Signs out of the SSO. Add ?redirect_uri= to return to a registered site's URL.
GET /api/directory/…Registered deviceJWT signed with the device keyOne user by Azure object ID, UPN or email (same shape as /userinfo, including the manager, reports, groups… the service may see). →

The prompt parameter (controls the sign-in screens)

Add prompt to /authorize to decide whether the user sees any screen this time and whether the password is asked again. The starters' /auth/login?silent=1 is prompt=none.

promptWhat the user seesWhen to use it
(not set)Already signed in to any service: passes straight through with no screen. Otherwise: the Microsoft sign-in screen (which may also pass straight through if Microsoft remembers the user).A normal “Sign in” button.
noneNever shows a screen. Signed in to the SSO → back with a code; not signed in → error=login_required; no access → error=access_denied.Try single sign-on automatically when the site opens; show your sign-in page only if it fails.
select_accountMicrosoft's “Pick an account” screen: choose an existing account (usually no password) or “Use another account”.A “Switch account” button; computers shared by several people.
loginAlways asks for the account and password again (plus the company's MFA), even when already signed in to the SSO or Microsoft.Re-confirm identity before sensitive actions (approvals, permission changes, salary data) or for high-security systems.
# No screen — only try whether automatic sign-in works
https://ae-sso.advantech.com/authorize?client_id=svc_xxxxxxxx&redirect_uri=…&response_type=code&state=RANDOM&prompt=none

# Force the password again
https://ae-sso.advantech.com/authorize?client_id=svc_xxxxxxxx&redirect_uri=…&response_type=code&state=RANDOM&prompt=login

# Add prompt in the starter's /auth/login
q["prompt"] = "login"                      # Python  (/auth/login)
q.set("prompt", "login");                  // Node.js
$q['prompt'] = 'login';                    // PHP

Parameters of the logout URL (/logout)

ParameterWhat it does
redirect_uriWhere to return after signing out; must be the address of a registered service (same domain).
microsoft=1Also sign out of the Microsoft account this time, so the password is asked next time (also signs the browser out of Outlook, Teams web apps).
microsoft=0Sign out of the site and the SSO only, even if the administrator turned on “Also sign out of Microsoft”.
(not set)Follows the administrator's “Azure AD settings → Sign-out behavior” (SSO only by default).

What you must build

The SSO and the front-end kit handle most of the work; the rest must live in your backend, because only your server can hold the Client Secret and decide who may do what.

FeatureWhoWhat it does
Passwords, MFASSO providesHandled by Microsoft; your site never sees a password.
Single sign-on across servicesSSO providesSigned in to any service → others pass automatically (the starters' /auth/login?silent=1).
User data, photo, manager / reportsSSO providesReturned at sign-in; fields follow the service's data permissions.
Sign-in button, page, user badgeFront-end kit providesadvantech-sso.js / .css and login.html.
/auth/loginYou build (starter has it)Creates a random state and redirects to the SSO.
/auth/callbackYou build (starter has it)Checks the state, calls /token with the code + Client Secret, creates the session. Always on the backend, because it needs the Client Secret.
/auth/meYou build (starter has it)Returns the current user JSON to the front-end kit; 401 when signed out.
/auth/logoutYou build (starter has it)Clears your session, then redirects to the SSO's /logout.
Session managementYou build (starter has it)Lifetime, storage, new session id after sign-in.
Protect pages and APIsYou build (starter has it)Every page and API that needs a signed-in user must check the session on the backend; hiding a button in the front end is not protection.
Authorization (who may do what)You must buildThe SSO tells you who the user is plus attributes such as department and groups; rules like “only AE may edit” are decided in your system.
Users in your systemYou must buildIf you store users (settings, orders ...), key them by sub, not email (emails change).
Refresh user dataOptionalSign-in data stays in your session; for fresh data call /userinfo while the access_token is valid (1 hour), or send the user through sign-in again (passes automatically).
Sign out of every service at onceOptionalNot supported. SSO sign-out ends only the SSO session; each site's session expires on its own.
Server-side user lookups (People & Groups API)OptionalIf needed, generate a key on the device and call /api/directory/* with a signed JWT — see “People & Groups API” in the basic guide.

Go-live checklist

Advantech Single Sign-On