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.
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.
| Part | Where | Responsible for |
|---|---|---|
| Browser | The user's computer | Shows the sign-in page / button / user badge (advantech-sso.js); only calls your site's /auth/* and never holds a secret. |
| Your backend | Your server | Keeps the Client Secret, handles /auth/login and /auth/callback, creates and checks its own session, protects pages and APIs. |
| Advantech SSO | https://ae-sso.advantech.com | Microsoft sign-in, single sign-on across services, allow / deny lists, user data and photos, sign-in log. |
| Microsoft Entra ID | login.microsoftonline.com | Passwords, MFA, Conditional Access. Your site never talks to it directly. |
Your site sees they are not signed in yet.
Your backend (/auth/login) redirects the browser to the SSO with a random check value (state).
The SSO checks whether they are already signed in; only if not, Microsoft asks for their work account and password.
The SSO redirects the browser to /auth/callback with a one-time “ticket” (code) and the same check value.
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.
Your backend keeps the user in its own session. Every later request just checks the session — no need to ask the SSO again.
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.
| Item | Need | What it does |
|---|---|---|
| Add a service | Required | Gives the Client ID and Client Secret. Service owners can request one under “My services”. |
| Redirect URI | Required | Register 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 read | Recommended | Allow only the fields the site really needs (e.g. department, manager). Team members and raw data are off by default. |
| Data masking | Optional | Administrators 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) | Optional | Limit which accounts or domains may sign in; refused users never reach your site. |
| People & Groups API devices | Optional | Only if a server must look users up with nobody signed in (batch jobs, sync); turned on and registered by a super administrator. |
| Item | Need | What it does |
|---|---|---|
| SSO_CLIENT_ID SSO_CLIENT_SECRET | Required | From the SSO. Keep the secret in environment variables or a secret store — never in code, HTML or Git. |
| APP_URL | Required | Your 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_SECRET | Required | Key that signs the session cookie: 32+ bytes and fixed. Changing it on every restart signs everyone out and causes error=state. |
| HTTPS | Required | Production must use https so the session cookie can be Secure. Plain http is allowed only for http://localhost. |
| Session storage | Recommended | The Node / Go starters keep sessions in memory: lost on restart and not shared between servers. Use Redis or a database in production. |
| Cookie settings | Recommended | HttpOnly, Secure (https), SameSite=Lax. Not SameSite=Strict — the cookie would be missing when the SSO redirects back. |
| Outbound access | Required | Your backend must reach https://ae-sso.advantech.com over https (for /token and /userinfo). |
| Content-Security-Policy | Optional | With 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) | Optional | For 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>
Reference these by URL or download them to your own site. The URLs are stable and will not be renamed.
| File | URL | What it does | |
|---|---|---|---|
| advantech-sso.js | https://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.css | https://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.svg | https://ae-sso.advantech.com/static/logo.svg | Download | Advantech logo (white on blue). |
| login.html | https://ae-sso.advantech.com/developers/files/login.html | Download | Complete sign-in page template. |
| index.html | https://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.
| Language | File | Full starter | |
|---|---|---|---|
| Python / Flask | flask_app.py | Download | .zip |
| Node.js / Express | express_app.mjs | Download | .zip |
| PHP | sso.php | Download | .zip |
| C# / ASP.NET Core | Program.cs | Download | .zip |
| Java / Spring Boot | SsoController.java | Download | .zip |
| Go | main.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).
| API | Called by | Authentication | What it does |
|---|---|---|---|
| GET /authorize | Browser | — | 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 /token | Your backend | Client ID + Secret | Form 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 /userinfo | Your backend | Bearer access_token | Send Authorization: Bearer <access_token> to get the user data. Access tokens last 1 hour. |
| GET /userinfo/photo | Your backend | Bearer access_token | The user's photo (the service also needs the "photo" field). |
| GET /photo/{token} | Browser | Signed URL (7 days) | Photo URL for <img src> (absent when the user has no photo) |
| GET /logout | Browser | — | Signs out of the SSO. Add ?redirect_uri= to return to a registered site's URL. |
| GET /api/directory/… | Registered device | JWT signed with the device key | One user by Azure object ID, UPN or email (same shape as /userinfo, including the manager, reports, groups… the service may see). → |
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.
| prompt | What the user sees | When 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. |
| none | Never 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_account | Microsoft'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. |
| login | Always 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. |
consent) are ignored, as if not set.select_account automatically for their next sign-in so they don't silently get the same account back.login_required / access_denied come back to your callback as errors only with prompt=none; otherwise the user deals with it on the SSO's or Microsoft's screen.# 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
| Parameter | What it does |
|---|---|
| redirect_uri | Where to return after signing out; must be the address of a registered service (same domain). |
| microsoft=1 | Also 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=0 | Sign 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). |
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.
| Feature | Who | What it does |
|---|---|---|
| Passwords, MFA | SSO provides | Handled by Microsoft; your site never sees a password. |
| Single sign-on across services | SSO provides | Signed in to any service → others pass automatically (the starters' /auth/login?silent=1). |
| User data, photo, manager / reports | SSO provides | Returned at sign-in; fields follow the service's data permissions. |
| Sign-in button, page, user badge | Front-end kit provides | advantech-sso.js / .css and login.html. |
| /auth/login | You build (starter has it) | Creates a random state and redirects to the SSO. |
| /auth/callback | You 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/me | You build (starter has it) | Returns the current user JSON to the front-end kit; 401 when signed out. |
| /auth/logout | You build (starter has it) | Clears your session, then redirects to the SSO's /logout. |
| Session management | You build (starter has it) | Lifetime, storage, new session id after sign-in. |
| Protect pages and APIs | You 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 build | The 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 system | You must build | If you store users (settings, orders ...), key them by sub, not email (emails change). |
| Refresh user data | Optional | Sign-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 once | Optional | Not supported. SSO sign-out ends only the SSO session; each site's session expires on its own. |
| Server-side user lookups (People & Groups API) | Optional | If needed, generate a key on the device and call /api/directory/* with a signed JWT — see “People & Groups API” in the basic guide. |
Advantech Single Sign-On