Introduction
Your users already have a Corenexis Account. This lets them use it to sign in to your app — you never handle their password, and you get a verified identity back.
One integration covers every way in: password, magic link, Google, GitHub, Microsoft and Facebook, plus two-factor authentication, the consent screen and device management. You do not add providers one at a time, and you do not maintain them.
Quick start
The whole integration, in order. Each step links to the section with the details.
- Create an app in the developer console. Your Corenexis account needs a verified email address and two-step verification turned on. §1
- Register your exact redirect URI, for example
https://yourapp.com/auth/callback. It is matched byte for byte. §1 - Choose your data access in the console's Data access section: name, email and account id are always included; country and timezone are optional. §12
- Redirect the user to Corenexis with a fresh
stateand a PKCES256code_challenge. §4 - Handle the callback: check
stateagainst your session andissagainsthttps://accounts.corenexis.com. Onerror=access_denied, show a signed-out page and never restart sign-in automatically. §5 - Exchange the code server-side within 60 seconds, sending
redirect_uriandcode_verifierwith your client credentials. §6 - Read
userfrom the response and key your records onuser.id. §7 - Store the rotating refresh token and replace it after every refresh. §9
Want the verified badge and the profile picture? Read App verification once your app is live.
Security requirements
These are enforced by the server. A request that breaks one of them is refused, so build them in from the first line.
- Exact redirect URI. The
redirectyou send must equal a registered URL byte for byte. Only a loopback address (http://127.0.0.1) may differ by port. - PKCE with S256. Every sign-in sends a
code_challengewithcode_challenge_method=S256;plainis refused. The exchange sends the matchingcode_verifier. stateis required. Up to 512 characters, unguessable, stored in your session. Verify it on the callback and reject a mismatch.- Check
iss. Every callback carriesiss=https://accounts.corenexis.com(RFC 9207). Reject a callback with any other value. - Repeat
redirect_uriin the token exchange, exactly as you sent it in the sign-in request. - Codes are single-use and expire after 60 seconds. Exchange them immediately, server-side.
- Refresh tokens rotate. Store the new one every time; presenting a retired token revokes the whole session.
- Never ship
client_secretin a browser, mobile or desktop app. Exchange codes through your own backend.
1. Create your app
Apps are created and managed on the identity platform itself — accounts.corenexis.com/developer. You need a Corenexis account with a verified email address and two-step verification turned on — an app owner can issue tokens for everyone who signs in to their app, so that account has to be the hardest one to steal. This site is documentation only; nothing is registered here.
| Field | Notes |
|---|---|
| Display name | What users see on the sign-in and consent screens. Use the real name of your app — it is the main thing people judge before approving. |
| Redirect URLs | Where we return the user. Matched exactly — the redirect you send must be one of these, character for character (only a loopback http://127.0.0.1 address may differ by port). One per line. Building a mobile or desktop app? Register your own scheme (com.yourapp.name://auth/callback) and read §11. |
| Website URLrequired | Shown on the consent screen, used as the "back to your app" exit on our error pages, and where a cancelling user is sent if there is no usable callback. Point it at a real landing page, not a deep link. |
| App logorequired | Uploaded, not linked. PNG, JPG or WebP, up to 1 MB — drag it onto the field or pick a file. We re-encode it to a 256×256 WebP and serve it from Corenexis, so the consent screen never fetches an image from your server: it stays fast, and your logo host never learns who signs in to you. A wide mark is padded onto the square, never cropped. SVG is not accepted. |
| Privacy policy URLrequired | Shown to users on the consent screen when they approve your app. An app that asks strangers for their email and profile should be able to say what it does with them. |
| Terms of service URLoptional | Shown next to your privacy policy on the consent screen, with the line “By continuing you agree to <your app>'s terms of service and privacy policy”. Required for verification (§13). |
| Token lifetimes | Fixed for self-service apps: access token 15 minutes, refresh token 7 days. |
| Data access | Chosen per app in the console's Data access section: name, email and account id are always included, country and timezone are optional, and the profile picture unlocks after verification. See §12. |
403 or a 404 is fine,
we are only confirming a server is really there. A link to a domain that does not exist is worse
than no link, and these end up on the screen where a user decides whether to trust you. http://localhost… is exempt while you develop.
You get back two values:
| Value | What it is |
|---|---|
client_id |
A generated, opaque identifier such as app_9f2c41ab7d05e8c3f1a6b204. It is public — it appears in redirect URLs and is safe to ship in config. You do not choose it, and users never see it; they see your display name. |
client_secret |
48 hex characters, shown exactly once. Only a bcrypt hash is stored, so it can never be recovered — if you lose it, rotate it from your app's page and redeploy. Treat it like a password: server-side only, never in a browser, mobile app or public repository. |
Store them in your app's environment:
CRX_BASE_URL=https://accounts.corenexis.com
CRX_CLIENT_ID=app_9f2c41ab7d05e8c3f1a6b204
CRX_CLIENT_SECRET=<the secret shown once>
CRX_CALLBACK_URL=https://yourapp.com/auth/callback
You can hold up to five apps per account, and you can suspend or delete any of them yourself.
2. Manage your app
Everything below is self-service from your app's page under Developer → Your apps. No ticket, no waiting.
| Action | What happens | When to use it |
|---|---|---|
| Edit | Name, logo, website and redirect URLs change immediately. Live sessions are unaffected. | Rebrand, new callback path, moving domains. |
| Rotate secret | A new secret is shown once; the old one stops working the moment you rotate. | The secret leaked, a developer left, or it is simply old. Deploy the new value first-thing after rotating. |
| Sign all users out | Every refresh token for your app is revoked. Access tokens keep verifying until they expire (they are self-contained JWTs). | Suspected compromise, or a breaking change to your session model. |
| Suspend | Sign-in redirects to your app are refused and every /api/token grant returns invalid_client. Fully reversible. | Taking the app offline for a while. |
| Delete | The app and all of its sessions are removed, and the client id can never be reused. | Permanent shutdown. Prefer suspending. |
3. The sign-in flow
Your app Corenexis Accounts Your server
│ │ │
1. └─ redirect user ────────────▶│ │
│ │ user signs in, approves │
2. │◀──── redirect back with ?code=… ──────────────────────▶ │
│ │ │
3. │ │◀── POST /api/token ────────┤
│ │ client_id + secret │
│ │──── access + refresh ─────▶│
│ │ token + user │
4. └─ your own session cookie ◀───────────────────────────────┘
Steps 1 and 2 happen in the browser. Steps 3 and 4 are server-to-server — the code is useless to anyone who does not also hold your client secret.
4. Send the user to us
Redirect the browser to the Corenexis sign-in page with your callback URL, URL-encoded, in redirect:
https://accounts.corenexis.com/?redirect=https%3A%2F%2Fyourapp.com%2Fauth%2Fcallback&state=8f2b…&code_challenge=E9Mel…&code_challenge_method=S256
/login and /signup accept ?redirect= too if you would rather
land users on one of those directly. From here we handle everything: password, magic link, Google,
GitHub, Microsoft, two-factor — and, the first time, the consent screen showing your app's name,
logo and exactly what will be shared.
redirect value must exactly equal one of your registered redirect URLs,
byte for byte (only a loopback http://127.0.0.1 address may differ by port).
If it does not match we stop and show the user a 400 error card naming the problem.
We never sign someone in to an app we cannot identify, and we never quietly drop them on their
dashboard. This mismatch is the single most common integration mistake.
Send a state — required
Generate an unguessable value per sign-in, keep it in your own session, and pass it alongside redirect. We return it unchanged on the callback:
https://accounts.corenexis.com/?redirect=https%3A%2F%2Fyourapp.com%2Fauth%2Fcallback&state=8f2b…&code_challenge=E9Mel…&code_challenge_method=S256
Refuse any callback whose state does not match the one you stored — that
is what stops someone feeding your app a callback it never asked for (RFC 6749 §10.12). It is opaque
to us: never parsed, never interpreted, only handed back. Maximum 512 characters; a request without a
state, or with a longer one, stops on our error page.
Send a PKCE challenge — required
Every sign-in request carries code_challenge and code_challenge_method=S256, derived
from a fresh code_verifier you keep in your session. How to build them is in §11; the rule applies to web apps too.
Go straight to a provider — optional
If your own screen already has a Continue with Google button, add provider and we
skip our sign-in page and open Google's account picker directly:
https://accounts.corenexis.com/?redirect=https%3A%2F%2Fyourapp.com%2Fauth%2Fcallback&state=8f2b…&code_challenge=E9Mel…&code_challenge_method=S256&provider=google
Accepted values: google, github, microsoft, facebook.
It is honoured only together with a valid redirect and only while that provider is enabled;
otherwise the normal sign-in page is shown. The picker appears even if the browser is already signed in
to Corenexis, because the user asked to choose an account. Everything after that is unchanged: the
account is a Corenexis account, and consent, the code and your callback work exactly as below.
5. Handle the callback
After a successful sign-in we send the browser back to your callback with a code:
https://yourapp.com/auth/callback?code=3f9c…64-hex-chars…7b&state=8f2b…&iss=https%3A%2F%2Faccounts.corenexis.com
If the user pressed Cancel on the consent screen you get an error instead — handle both:
https://yourapp.com/auth/callback?error=access_denied&state=8f2b…&iss=https%3A%2F%2Faccounts.corenexis.com
Check state and iss first
Before you look at code or error, compare state with the value in your session
and confirm iss is exactly https://accounts.corenexis.com (RFC 9207). Every callback carries
both, success or error. Reject anything that does not match, and clear the stored state so it cannot be used twice.
Cancel: what your app must do
When you receive error=access_denied, show your signed-out page — a landing page, or a sign-in screen with a button the user has to press.
/api/me call returns 401, and the app redirects
into SSO again. The user is then straight back on the consent screen they just dismissed, with no way
out — and it reads as our bug, not yours. "The user declined" is a state your app should be
able to sit in, exactly like a sign-out.
Your policy links on the consent screen
If your app has a privacy policy URL or a terms URL, the consent screen shows them under your app's name and closes with “By continuing you agree to <your app>'s terms of service and privacy policy” — the same treatment Google and Microsoft give a client's own policies. Set neither and nothing is rendered: users are never shown a link that goes nowhere. Both live on your app's page and take effect immediately.
As a safety net we refuse to render the consent screen twice in a row for an app the user just declined: the second request inside a short window gets a dead-end page with links back to your app and to their account. That stops the loop, but it is a guard rail, not a substitute for handling the error.
The code is single use and expires in 60 seconds. Exchange it immediately, server-side.
6. Exchange the code for tokens
Server-to-server, within 60 seconds of receiving the code. Pick your language — the choice sticks for every sample on this page.
curl -X POST https://accounts.corenexis.com/api/token \
-d grant_type=authorization_code \
-d code="$CODE" \
-d client_id="$CRX_CLIENT_ID" \
-d client_secret="$CRX_CLIENT_SECRET" \
-d code_verifier="$PKCE_VERIFIER" \
-d redirect_uri="https://yourapp.com/auth/callback"// Express callback route
app.get('/auth/callback', async (req, res) => {
if (!req.session.oauthState || req.query.state !== req.session.oauthState) return res.status(400).send('bad state');
if (req.query.iss !== 'https://accounts.corenexis.com') return res.status(400).send('bad issuer');
delete req.session.oauthState; // one use per sign-in
if (req.query.error) return res.redirect('/?signin=cancelled'); // signed-out page, no auto-retry
const r = await fetch(process.env.CRX_BASE_URL + '/api/token', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({
grant_type: 'authorization_code',
code: req.query.code,
client_id: process.env.CRX_CLIENT_ID,
client_secret: process.env.CRX_CLIENT_SECRET,
code_verifier: req.session.pkceVerifier,
redirect_uri: 'https://yourapp.com/auth/callback',
}),
});
const tok = await r.json();
if (!r.ok) throw new Error(tok.error_description || tok.error);
// Pin your session to the returned account — see the warning in §7.
req.session.userId = tok.user.id;
req.session.refreshToken = tok.refresh_token;
res.redirect('/');
});<?php
// /auth/callback.php
session_start();
$expected = $_SESSION['oauth_state'] ?? '';
unset($_SESSION['oauth_state']); // one use per sign-in
if ($expected === '' || !hash_equals($expected, $_GET['state'] ?? '')) { http_response_code(400); exit('bad state'); }
if (($_GET['iss'] ?? '') !== 'https://accounts.corenexis.com') { http_response_code(400); exit('bad issuer'); }
if (isset($_GET['error'])) { header('Location: /?signin=cancelled'); exit; } // signed-out page, no auto-retry
$ch = curl_init(getenv('CRX_BASE_URL') . '/api/token');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
CURLOPT_POSTFIELDS => http_build_query([
'grant_type' => 'authorization_code',
'code' => $_GET['code'],
'client_id' => getenv('CRX_CLIENT_ID'),
'client_secret' => getenv('CRX_CLIENT_SECRET'),
'code_verifier' => $_SESSION['pkce_verifier'],
'redirect_uri' => 'https://yourapp.com/auth/callback',
]),
]);
$tok = json_decode(curl_exec($ch), true);
curl_close($ch);
if (!empty($tok['error'])) { throw new RuntimeException($tok['error_description']); }
$_SESSION['user_id'] = $tok['user']['id']; // pin to this account
$_SESSION['refresh'] = $tok['refresh_token'];
header('Location: /');# Flask callback route
import os, requests
from flask import request, session, redirect
@app.get("/auth/callback")
def callback():
expected = session.pop("oauth_state", None) # one use per sign-in
if not expected or request.args.get("state") != expected:
return "bad state", 400
if request.args.get("iss") != "https://accounts.corenexis.com":
return "bad issuer", 400
if request.args.get("error"):
return redirect("/?signin=cancelled") # signed-out page, no auto-retry
r = requests.post(
os.environ["CRX_BASE_URL"] + "/api/token",
data={
"grant_type": "authorization_code",
"code": request.args["code"],
"client_id": os.environ["CRX_CLIENT_ID"],
"client_secret": os.environ["CRX_CLIENT_SECRET"],
"code_verifier": session["pkce_verifier"],
"redirect_uri": "https://yourapp.com/auth/callback",
},
timeout=10,
)
tok = r.json()
r.raise_for_status()
session["user_id"] = tok["user"]["id"] # pin to this account
session["refresh"] = tok["refresh_token"]
return redirect("/")
HTTP Basic works too — Authorization: Basic base64(client_id:client_secret) instead of the two body fields.
Send redirect_uri with the exchange (RFC 6749 §4.1.3). It must be exactly the redirect the code was issued for, or the exchange fails with invalid_grant. Send code_verifier too: the verifier you derived the sign-in's code_challenge from.
What comes back
{
"access_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6…",
"token_type": "Bearer",
"expires_in": 900,
"refresh_token": "a1b2c3…",
"refresh_expires_in": 604800,
"user": {
"id": "9c1f8e42-5b7a-4d3e-9a11-72c4e8f0b5d6",
"name": "Someone",
"email": "someone@example.com",
"email_verified": true
}
}
The user object above holds the fields every app receives. Fields from optional scopes appear
only when your app has them enabled (and, for the picture, only while the app is verified):
"country": "GB", // locale, only if enabled
"timezone": "Europe/London", // locale, only if enabled
"avatar_url": "https://…/abc123.webp" // picture, verified apps only; null if unset
7. What your app receives
An app only ever receives the fields it has been granted. Everything else is stripped from both /api/token and /api/userinfo — there is no
way to ask for more at request time, and a user is never shown a permission your app cannot use.
| Field | Type | Notes |
|---|---|---|
id | uuid | The stable identifier, always present. Key everything on this. |
name | string · nullable | Display name. profile scope, always included. |
email | string | email scope, always included. Can change — never use it as a primary key. |
email_verified | bool | Check it before trusting the address. |
country / timezone | string · nullable | ISO 3166-1 alpha-2 and an IANA zone. Only with the optional locale scope. |
avatar_url | string · nullable | Profile picture URL; null if the user has set no picture. Only with the picture scope, which verified apps can enable. Append ?s=<width> for a resized copy. |
null.
Write your code against the Data access list on your app's page. Phone number and security status are
never released to self-service apps (§12).
user.id. Skip this and someone who switches accounts stays
logged in as the previous one.
8. Verifying the access token
The access token is an RS256 JWT. You do not have to verify it for a plain login — it came straight from us over TLS. Verify when your API receives the token from somewhere else.
Public keys: https://accounts.corenexis.com/.well-known/jwks.json
Discovery: https://accounts.corenexis.com/.well-known/openid-configuration
import { createRemoteJWKSet, jwtVerify } from 'jose';
const JWKS = createRemoteJWKSet(
new URL(process.env.CRX_BASE_URL + '/.well-known/jwks.json'));
const { payload } = await jwtVerify(accessToken, JWKS, {
issuer: process.env.CRX_BASE_URL,
audience: process.env.CRX_CLIENT_ID,
});
// payload.sub === the user's id
Check iss, aud and expiry. Cache the JWKS — keys rotate rarely, and each key carries a kid.
9. Refreshing and signing out
Refresh. Refresh tokens rotate: every refresh returns a new one and retires the old. Always store the newest.
POST https://accounts.corenexis.com/api/token
grant_type=refresh_token
&refresh_token=<current refresh token>
&client_id=<your client_id>
&client_secret=<your client_secret>
Sign out. Revoke the refresh token when the user logs out of your app.
POST https://accounts.corenexis.com/api/token
grant_type=revoke
&refresh_token=<current refresh token>
&client_id=<your client_id>
&client_secret=<your client_secret>
10. Fetching the profile later
GET https://accounts.corenexis.com/api/userinfo
Authorization: Bearer <access_token>
Returns the same user object, fresh, limited to the scopes your app has enabled and is allowed right now. Use it when you want current details rather than the copy from sign-in time.
11. Android, iOS and desktop apps
A native app has no https address to come back to, so register your own scheme as the redirect URL and the operating system hands the callback to your app.
com.yourapp.name://auth/callback
Open the sign-in URL in the system browser (or a Custom Tab / ASWebAuthenticationSession), with your scheme URL-encoded:
https://accounts.corenexis.com/?redirect=com.yourapp.name%3A%2F%2Fauth%2Fcallback
&state=<random>&code_challenge=<challenge>&code_challenge_method=S256
The user signs in and the OS routes this straight back into your app:
com.yourapp.name://auth/callback?code=<authorization_code>&state=<random>&iss=https%3A%2F%2Faccounts.corenexis.com
Android — the two pieces of wiring
Declare the scheme on the activity that should receive the callback:
<!-- AndroidManifest.xml -->
<activity android:name=".AuthCallbackActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="com.yourapp.name" android:host="auth" />
</intent-filter>
</activity>
Open sign-in in a Custom Tab — never a WebView, which hides the address bar the user needs to trust the page:
// Kotlin
val verifier = randomVerifier() // 43–128 chars, A-Z a-z 0-9 - . _ ~
val challenge = base64UrlNoPad(sha256(verifier)) // S256
store(verifier) // survives the app being backgrounded
val url = Uri.parse("https://accounts.corenexis.com/")
.buildUpon()
.appendQueryParameter("redirect", "com.yourapp.name://auth/callback")
.appendQueryParameter("state", state)
.appendQueryParameter("code_challenge", challenge)
.appendQueryParameter("code_challenge_method", "S256")
.build()
CustomTabsIntent.Builder().build().launchUrl(context, url)
// AuthCallbackActivity.onCreate — the OS delivers the code here
val code = intent?.data?.getQueryParameter("code")
// POST { code, code_verifier } to YOUR backend, which does the real exchange.
code. That code is harmless on its own — the exchange in §6 still requires the secret — so
send it to your own server and exchange it there. Put the secret in the app and an attacker who
catches a code has both halves.
your app ──code + verifier──▶ your backend ──code + verifier + client_secret──▶ /api/token
│
└──▶ returns your own session token to the app
A desktop app can instead open a short-lived local listener and register http://127.0.0.1:<port>/callback — that is accepted too. Either way a bare scheme
(com.yourapp.name://) is rejected: register the full callback path.
https callback hands the result on to your app
(https://yourapp.com/auth/callback → 302 → com.yourapp.name://auth?…): register com.yourapp.name://auth as a redirect URL too. Otherwise a new user's first sign-in stops on the
consent screen, while returning users (who skip consent) work fine — a confusing bug to chase.
On Android, verified apps can also sign people in without a browser through the Corenexis app, described next. The browser flow above stays the fallback for everyone.
Android — one-tap sign-in with the Corenexis app
When the Corenexis app is installed, your Android app can sign people in without a browser: your app opens the Corenexis app, the person sees your app's name and what it receives, confirms with their fingerprint, and you get an authorization code back, just like signing in with Google. Without the Corenexis app (or without a Corenexis account on the phone) use the Custom Tab flow above.
- Register your Android app. In the developer console, open your app > Android apps and add one line per signing certificate: your package name and the certificate's SHA-256 fingerprint. Add the Google Play app signing key (Play Console > Test and release > App integrity) and your upload key for test builds.
-
Get your app verified. One-tap sign-in works only for verified apps (§13). Until then the
Corenexis app answers
unauthorized_clientand your app falls back to the browser. - Call the Corenexis app and send the result to your server:
A ready-to-copy helper, a server example and this guide are on GitHub: Core-Nexis/sign-in-with-corenexis.
<!-- AndroidManifest.xml: let your app see the Corenexis app (Android 11+) -->
<queries>
<package android:name="com.corenexis.app" />
</queries>
// Kotlin: sign in through the Corenexis app, with the browser as the fallback.
object CorenexisSignIn {
private const val PACKAGE = "com.corenexis.app"
private const val ACTION = "com.corenexis.signin.AUTHORIZE"
// SHA-256 of the certificate Google Play signs the Corenexis app with.
private const val CORENEXIS_CERT =
"D0:A0:31:5D:26:4D:98:C0:C3:12:CE:EA:B7:7A:8F:0D:E3:05:E8:D4:C9:6F:54:4F:4C:E8:1E:02:5F:63:45:75"
/** True only when the genuine Corenexis app is installed (checked by its signature). */
fun isAvailable(context: Context): Boolean = runCatching {
val pm = context.packageManager
val info = pm.getPackageInfo(PACKAGE, PackageManager.GET_SIGNING_CERTIFICATES)
val signing = info.signingInfo ?: return false
if (signing.hasMultipleSigners()) return false
val cert = signing.signingCertificateHistory.last().toByteArray()
val sha = MessageDigest.getInstance("SHA-256").digest(cert).joinToString(":") { "%02X".format(it) }
sha == CORENEXIS_CERT && pm.resolveActivity(Intent(ACTION).setPackage(PACKAGE), 0) != null
}.getOrDefault(false)
fun intent(clientId: String, codeChallenge: String, state: String): Intent =
Intent(ACTION).setPackage(PACKAGE)
.putExtra("client_id", clientId)
.putExtra("code_challenge", codeChallenge)
.putExtra("code_challenge_method", "S256")
.putExtra("state", state)
}
// In your Activity or Fragment
private var verifier = ""
private var state = ""
private val corenexis = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { r ->
val data = r.data
if (r.resultCode == Activity.RESULT_OK && data?.getStringExtra("state") == state) {
val code = data.getStringExtra("code")!!
// Send code + verifier to YOUR server; it exchanges them (with the client secret).
sendToBackend(code, verifier, redirectUri = data.getStringExtra("redirect_uri")!!)
} else when (data?.getStringExtra("error")) {
"access_denied" -> Unit // the person closed it
else -> openBrowserSignIn() // no account on the phone, not set up, etc.
}
}
fun signIn() {
verifier = newCodeVerifier() // see "PKCE" below
state = newState()
if (CorenexisSignIn.isAvailable(this)) {
corenexis.launch(CorenexisSignIn.intent(CLIENT_ID, codeChallenge(verifier), state))
} else {
openBrowserSignIn() // the Custom Tab flow above
}
}
Your server exchanges the code exactly as in §6, with redirect_uri=android:<your package>:
POST https://accounts.corenexis.com/api/token
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code
&code=<code from the Corenexis app>
&code_verifier=<the verifier your app made>
&redirect_uri=android:com.example.app
&client_id=<client id>
&client_secret=<client secret, on your server only>
isAvailable above) so a look-alike app cannot pretend to be it,
and always compare the returned state.
Result extras: code, state and redirect_uri on success; on cancel or
failure error (access_denied, no_account, unauthorized_client,
invalid_request) and error_description. iOS and desktop apps use the browser flow
above for now.
PKCE — required for every app
PKCE (RFC 7636) ties the code to a secret your app generates fresh for each sign-in, so a code caught
by another app or another site is useless on its own. It is required (RFC 9700): a
sign-in request without a code_challenge stops on our error page, and the exchange must send
the matching code_verifier.
code_challenge = BASE64URL( SHA256( code_verifier ) )
code_challenge_method = S256
Then send the verifier with the exchange in §6:
grant_type=authorization_code&code=…&client_id=…&client_secret=…&code_verifier=<verifier>&redirect_uri=<the exact redirect you sent>
Only S256 is accepted — plain defeats the point. PKCE does not replace the client secret here: the exchange still needs it, so keep doing it from your backend. PKCE is
the layer on top that makes a custom-scheme callback safe.
12. Data access (scopes)
You choose what your app receives, per app, in the Data access section of your app's page in the
developer console. Each item maps to a scope, and the scope decides which fields appear in user.
| Tier | Scope | Fields | Who can use it |
|---|---|---|---|
| Always included | (subject) | id | Every app. The stable account id is always present; it is the subject, not a scope you switch on. |
| Always included | profile | name | Every app, unverified apps included. |
| Always included | email | email, email_verified | Every app, unverified apps included. |
| Optional | locale | country (ISO 3166-1 alpha-2), timezone (IANA) | Any app, when the developer turns it on. Unverified apps included. |
| Verified apps only | picture | avatar_url (profile picture URL; null when the user has set no picture) | Verified apps, when the developer turns it on after verification. Shown locked as Available after verification in the console until then. |
| Not available | phone, security | Phone number; two-step status and account creation date | First-party Corenexis products only. Self-service apps cannot enable these. |
profile now means the name only. The profile picture moved to its own picture
scope. If your code reads avatar_url, treat it as optional: it is absent unless your app is verified and has
picture enabled.
How it is enforced
Enforcement is server-side. The user object in the token response, /api/userinfo, the
access token's scope claim and the consent screen all use exactly the scopes your app has enabled
and is allowed to use. Nothing in the sign-in request can widen that set, and a user is never shown a permission
your app would not receive.
- Losing verification stops
pictureimmediately:avatar_urldisappears from new responses and from/api/userinfo, even if the scope is still switched on. - Enabling a new scope means existing users are asked to consent again the next time they sign in, for the new item only. A scope added later is never handed over silently.
13. Getting your app verified
A self-service app that is not verified is labelled Unverified app on the consent screen, in the developer console and in emails. That label is honest, and sign-in works exactly the same with it.
Verification:
- removes the Unverified app label;
- shows the verified badge (a tick) next to your app's name on the consent screen;
- unlocks verified-only data: the profile picture (
picturescope).
You apply from your app's Verification tab in the developer console. Before you can submit, the app needs a name and logo that match your website, live homepage, privacy policy and terms URLs on one registrable domain, a use case, a verified DNS TXT record and a demo video. Most reviews finish within 3 to 5 business days.
14. Errors
Before the user reaches your callback
Some requests are stopped at Corenexis. The user sees an error page on accounts.corenexis.com, the flow ends there, and nothing is sent to your callback — no code, no error parameter. That is deliberate: an auth error must never be forwarded to a
URL we could not verify.
| What the user sees | Why | Fix |
|---|---|---|
| "We don't recognise that app" | Your redirect does not exactly match a URL registered for your app, or the app is suspended | Compare the exact URL you send with what is on your app's page. By far the most common mistake. |
| "This sign-in request has expired" | They landed on the consent screen with no pending request — usually a bookmarked or stale URL | Always start the flow from your app; never link users straight to /consent |
| "This sign-in request has already been used" | The consent form was submitted twice — back button, double click, or a retry after your callback failed to load | Their approval is already saved. Send them through sign-in again; they will not be asked twice. |
https://app.example.com/auth/callback does not match a registration of https://app.example.com/callback, a trailing slash
counts, and so does an added query string (carry such values in state). Paths with .. or encoded slashes are refused. If sign-in dies at the very first hop, check this before anything else.
At the token endpoint
Token errors are standard OAuth 2.0 JSON with the matching HTTP status:
{ "error": "invalid_grant", "error_description": "Code is invalid, expired or already used." }
| Error | Meaning | What to do |
|---|---|---|
invalid_client | Unknown client_id, wrong secret, or the app is suspended | Check both values, and that the app is active on its page |
invalid_grant | Code expired (60s), already used, issued to another client, or the refresh token was revoked | Restart the sign-in flow |
invalid_grant (retired token) | A refresh token that had already been rotated away was presented — treated as replay, so the session was revoked | Sign the user in again, then fix the retry/storage bug that resent it |
invalid_grant (code_verifier) | The code_verifier was missing or did not match the sign-in's code_challenge | Send the same code_verifier you derived the challenge from |
invalid_grant (redirect_uri) | The redirect_uri was missing, or differs from the one the code was issued for | Send the exact same value you used in the sign-in request |
unsupported_grant_type | Not one of the three grants | Use authorization_code, refresh_token or revoke |
slow_down | Rate limited | Back off and retry |
access_denied | The user pressed Cancel (arrives on your callback, not here) | Show a friendly "sign-in cancelled" — and do not re-enter SSO |
15. Security rules
- Register exact callback URLs. Redirect URLs are matched exactly; register each full callback you use, and nothing broader.
- Use PKCE (S256) on every sign-in and send
redirect_uriwith the code exchange. - Never ship the client secret to a browser or mobile app. There is no public-client flow here; if you cannot keep a secret, you need a small backend.
- Exchange the code immediately, server-side. 60 seconds, one use.
- Send a
stateand verify it — reject any callback whose state does not match the one you stored. - Check
isson every callback — it must be exactlyhttps://accounts.corenexis.com(RFC 9207). - Handle
error=access_deniedwithout restarting sign-in. See §5. - Pin the session to
user.idafter every exchange. - Never key records on the email address. It can change;
idcannot. - Store refresh tokens encrypted at rest, and always replace them after a refresh.
- Rotate the secret immediately if it ever appears in a log, a repository or a screenshot.
- We never send you the user's password, 2FA codes or backup codes. Nothing you receive can be used to sign in as them anywhere else.
Before you go live
- Callback registered as a full URL, and the
redirectyou send is exactly that URL. - Every sign-in sends
stateand a PKCE S256 challenge; the exchange sendscode_verifierandredirect_uri. - Website URL, app logo and privacy policy set — all three appear on the consent screen, and users decide whether to trust you from them.
- You send
stateand reject a mismatch, and you reject a callback whoseissis nothttps://accounts.corenexis.com. - Data access lists only what your app uses; you read optional fields such as
avatar_urlas possibly absent. - Your callback handles three outcomes:
code,error=access_denied, and neither (someone opened the URL directly). - Cancel leaves the user on your signed-out page — no automatic re-entry into SSO.
- The code is exchanged server-side within 60 seconds, and the secret is not in your client bundle.
- Your records are keyed on
user.id, never the email address. - Native or desktop app? You are using PKCE and exchanging through your own backend — see §11.
- Web callback that hands off to your app? The app URL is registered too, and you have tested a brand-new account through the consent screen — see §11.
- You have tested a second sign-in: consent must not appear again, and a refresh must return a new refresh token that you store in place of the old one.
16. Endpoint reference
| Endpoint | Method | Auth | Purpose |
|---|---|---|---|
/?redirect=… | GET | — | Start sign-in (browser) |
/api/token | POST | client_id + secret | Code exchange, refresh, revoke |
/api/userinfo | GET | Bearer access token | Current profile |
/.well-known/jwks.json | GET | — | Public keys for JWT verification |
/.well-known/openid-configuration | GET | — | Discovery document |
All of them live under https://accounts.corenexis.com.
17. FAQ
- Can I choose my own client ID?
- No. Self-service apps get a generated opaque ID so no app can impersonate a first-party Corenexis product. Users identify your app by its display name and logo, not its ID.
- Will my app show up on other people's Corenexis dashboards?
- No. Apps you create are private — reachable only through the sign-in link you send users, and clearly marked Unverified app on the consent screen until they are verified.
- How do I remove the "Unverified app" label?
- Get the app verified from its Verification tab in the developer console. The steps, requirements and review timeline are in App verification.
- Where do I get help?
- Visit help.corenexis.com.
- I lost the client secret.
- It cannot be recovered — only a bcrypt hash is stored. Rotate it from your app's page and redeploy with the new value. The old secret stops working the moment you rotate.
- How do I test without a second account?
- Corenexis supports several accounts in one browser: add another from the account menu and switch between them. That is also the fastest way to check your account pinning is right.
- Do you support OpenID Connect discovery?
- Yes —
/.well-known/openid-configurationand a JWKS endpoint. Access tokens are RS256 JWTs, so a standard OAuth 2.0 client library is all you need. - What happens when I suspend my app?
- Sign-in redirects to it are refused and every
/api/tokengrant returnsinvalid_client. Existing access tokens still verify until they expire, but nothing new can be issued. Fully reversible.
Create an app, copy the two values into your environment, and you can have sign-in working today.
Create an app