Step 2 — Starting a verification
Send the user to Hub to begin verification, using either a standard request or PAR.
To verify a user, you send them to Hub. This page shows you how to build that request.
There are two ways to do it. Both do the same job and both end with the user's browser at Hub.
Which one do I use?
| Use | When |
|---|---|
Standard — GET /auth | Default. Use this unless something below applies. |
PAR — POST /auth/par | Required if subject matching is enabled for your client. Also use it if you'd rather send the request from your backend than build a long URL in the browser. |
PAR stands for Pushed Authorization Request. Instead of putting the whole request in a URL, you POST it to Hub from your server first, and Hub gives you back a short URL to send the user to.
If you're not sure, use Standard. Your Interac representative will tell you if your client needs PAR.
Before you start
You need three things:
- Your client ID and scope, from onboarding
- Your RSA private key, to sign the request
- The endpoints from discovery
Step 1 — Build the signed request object
Both methods need this. It's a JWT that you sign with your private key, and it holds the details of what you're asking Hub to do.
Hub checks the signature against the public key at your JWKS URL. That's how Hub knows the request really came from you.
Header
{
"alg": "RS256",
"kid": "cIlDeR8D4RexrZmUdKhBxMsD2bMX4l87_5JrARh4VIU"
}
kidis required. It tells Hub which key from your JWKS URL to check the signature against. Without it, Hub can't verify your request.
Payload
{
"iss": "3f6c1a2e-8b47-4d19-9e52-7a0c4b6d1f83",
"aud": "{hub_base_url}/",
"client_id": "3f6c1a2e-8b47-4d19-9e52-7a0c4b6d1f83",
"response_type": "code",
"scope": "openid onlyVme_scope",
"redirect_uri": "https://acme-widgets.example.com/callback",
"state": "5de789881cc944a78e9c1c9d947f7867",
"nonce": "abdd5eed89834b62aee2de7a6ed4d92e",
"ui_locales": "en-CA"
}What each field means
| Field | Required | Type | What it is |
|---|---|---|---|
iss | Yes | String | Who's making the request. Must be your client_id. |
aud | Yes | String | Who it's for. Use the issuer value from discovery. |
client_id | Yes | String | Your client ID from onboarding. |
response_type | Yes | String | Always code. |
scope | Yes | String | openid plus one of your configured scopes. See Scopes. |
redirect_uri | Yes | String | Where Hub sends the user when it's done. Must be registered during onboarding. |
state | Yes | String | A random value you generate per verification. See below. |
nonce | No | String | A random value that protects against replay attacks. Returned unchanged in the ID token. |
ui_locales | No | String | en-CA or fr-CA. Sets the starting language. |
exp | No | Number | When this request object expires, as a Unix timestamp in seconds. |
code_challenge | No | String | For PKCE. See Optional: add PKCE. |
code_challenge_method | No | String | S256 if you're using PKCE. |
subject | Only for subject matching | Object | The user details you already hold. See Subject matching. |
expis a number, not a string. Write"exp": 1767225600, not"exp": "1767225600". Hub rejects a quoted timestamp, and the error won't mentionexp. With PAR, it's reported as a signature failure. The same applies toiatandnbfif you include them.
stateis required. Generate a unique random value for each verification and store it with the user's session. In Step 3, you match the returnedstateto that session to confirm the response belongs to that user.
Keep yourstatevalues after the flow ends. Hub recordsstateas soon as your request arrives, so it's what support uses to trace a transaction — including when a request fails before the user is ever redirected back. See Logstatefor every verification.
Optional: add PKCE
PKCE (say "pixy") stops an intercepted code from being useful to anyone else. It's optional but recommended. If you use it, it starts here, before you sign the request object.
- Generate a code verifier and code challenge pair with a PKCE library. Don't build the encoding by hand. A small mistake makes the token exchange fail. .NET has no widely used PKCE library, so the C# example uses its built-in functions.
- Add
code_challengeand"code_challenge_method": "S256"to the payload above. - Store the code verifier with the user's session, alongside
state. You'll send it in Step 4.
import pkce # pip install pkce
code_verifier, code_challenge = pkce.generate_pkce_pair()import pkceChallenge from "pkce-challenge"; // npm install pkce-challenge
const { code_verifier, code_challenge } = await pkceChallenge();// com.nimbusds:oauth2-oidc-sdk
import com.nimbusds.oauth2.sdk.pkce.CodeChallenge;
import com.nimbusds.oauth2.sdk.pkce.CodeChallengeMethod;
import com.nimbusds.oauth2.sdk.pkce.CodeVerifier;
CodeVerifier codeVerifier = new CodeVerifier();
CodeChallenge codeChallenge = CodeChallenge.compute(CodeChallengeMethod.S256, codeVerifier);using System.Buffers.Text;
using System.Security.Cryptography;
using System.Text;
var codeVerifier = Base64Url.EncodeToString(RandomNumberGenerator.GetBytes(32));
var codeChallenge = Base64Url.EncodeToString(SHA256.HashData(Encoding.ASCII.GetBytes(codeVerifier)));For other languages, search your package manager for "PKCE".
Only the challenge goes to Hub in this step. Keep the verifier on your server until Step 4.
Sign it
Pass the header and payload to your JWT library's sign function, along with your private key. It returns a single string: three base64url-encoded parts joined by dots (header.payload.signature). It always starts with eyJ.
That string is the request object. Send it as-is in the request parameter in Step 2. Don't send the JSON payload itself.
Step 2 — Send the user to Hub
Follow the section that matches your method.
Standard: GET /auth
GET /authBuild a URL and redirect the user's browser to it.
{hub_base_url}/auth
?request=eyJhbGciOiJSUzI1NiIsImtpZCI6ImNJbERlUjhE...
&response_type=code
&client_id=3f6c1a2e-8b47-4d19-9e52-7a0c4b6d1f83
&scope=openid+onlyVme_scope
&state=5de789881cc944a78e9c1c9d947f7867
&redirect_uri=https%3A%2F%2Facme-widgets.example.com%2FcallbackHTTP/1.1 302 Found
Location: {hub_base_url}/auth
?request=eyJhbGciOiJSUzI1NiIsImtpZCI6ImNJbERlUjhE...
&response_type=code
&client_id=3f6c1a2e-8b47-4d19-9e52-7a0c4b6d1f83
&scope=openid+onlyVme_scope
&state=5de789881cc944a78e9c1c9d947f7867
&redirect_uri=https%3A%2F%2Facme-widgets.example.com%2FcallbackThe HTTP tab is the redirect response your server sends to the user's browser. The URL is split across lines for readability. It's sent as a single line.
The request parameter is the signed JWT from Step 1. The rest repeat the same values as plain query parameters.
The user lands on the Hub verification screens. When they finish, Hub redirects them to your redirect_uri. Go to Step 3 — Handling the redirect.
PAR: POST /auth/par
POST /auth/parTwo parts: your server POSTs the request, then you redirect the user.
a. POST the request from your backend
Pick the tab you prefer. curl runs as-is in a terminal. HTTP shows exactly what's sent, so you can rebuild it with any HTTP library.
curl -X POST '{hub_base_url}/auth/par' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'request=eyJhbGciOiJSUzI1NiIsImtpZCI6ImNJbERlUjhE...' \
-d 'response_type=code' \
-d 'client_id=3f6c1a2e-8b47-4d19-9e52-7a0c4b6d1f83' \
-d 'scope=openid onlyVme_scope' \
-d 'state=5de789881cc944a78e9c1c9d947f7867' \
-d 'redirect_uri=https://acme-widgets.example.com/callback'POST {hub_base_url}/auth/par HTTP/1.1
Content-Type: application/x-www-form-urlencoded
request=eyJhbGciOiJSUzI1NiIsImtpZCI6ImNJbERlUjhE...
&response_type=code
&client_id=3f6c1a2e-8b47-4d19-9e52-7a0c4b6d1f83
&scope=openid+onlyVme_scope
&state=5de789881cc944a78e9c1c9d947f7867
&redirect_uri=https%3A%2F%2Facme-widgets.example.com%2FcallbackIn the HTTP tab, the body is split across lines for readability. It's sent as a single line. Your HTTP library normally URL-encodes the values for you.
b. Redirect the user to user_href
Hub replies with 201 and a URL:
{
"request_uri": "urn:example:hub:0584f83b-2995-4bc5-9c76-b43ebd4257f1",
"expires_in": 90,
"user_href": "{hub_base_url}/auth/par?request_uri=urn%3Aexample%3Ahub%3A0584f83b-2995-4bc5-9c76-b43ebd4257f1"
}Treat request_uri as an opaque value. Its format can change, so don't parse it or build it yourself.
Redirect the user's browser to user_href. From there it's identical to the standard flow — the user verifies, then Hub redirects them to your redirect_uri.
user_hrefexpires quickly. Redirect the user as soon as you get it — don't store it for later.
Which value wins if I set it twice?
You send several values in two places: inside the signed JWT and as plain parameters. If they disagree:
| Field | Winner |
|---|---|
| Most fields | The JWT. Values in the signed request object override plain parameters. |
nonce | The JWT. If nonce is in both, the plain parameter is ignored. |
Simplest approach: put everything in the JWT, and make the plain parameters match exactly.
Common mistakes
| Problem | Cause |
|---|---|
invalid_scope error on the redirect | The scope isn't configured for your client, or you left off openid. openid must come first. |
| Hub rejects your signature | Missing kid in the JWT header, your JWKS URL isn't reachable from the internet, or exp is a string or already in the past. |
redirect_uri mismatch | The URI must match a registered one exactly — including scheme, path and trailing slash. |
Discrepancy between 'redirect_uri' from JWT... | The request object and the query string carry different values. They must be identical. |
| You can't match the response to a user | You reused or didn't store state. |
PAR returns 400 | Subject matching is enabled but subject is missing, or a field failed validation. |
Next
Updated 3 days ago