Skip to main content
This page explains each step of the Monei Connect OAuth 2.0 Authorization Code Flow in detail including edge cases, error handling, and things that trip developers up.

Overview


Step 1: Build the authorization URL

Redirect your user to:

Parameters

Generating state

Always generate state fresh per request and store it in the user’s session:

Step 2: User approves on Monei

The user lands on Monei’s consent screen. If not logged in to Monei, they are prompted to log in first. The consent screen shows:
  • Your app name and logo (from registration)
  • Every scope you requested, in plain English
  • A clear allow / deny choice per scope
Users control individual scope approvals. They can approve wallet:read but deny wallet:send. Your app must handle this. See Partial Grants.

Step 3: Monei redirects back

On approval

The code is short-lived, exchange it within 10 minutes or it expires.

On denial

Handle this gracefully and show the user what features won’t be available and offer to try again.

Validating state

Always compare the returned state to what you stored before proceeding:

Step 4: Exchange the code for tokens

This must happen server-side. Never expose your client_secret in frontend or mobile code.

Response

The scopes array reflects what the user actually approved — not everything you requested. A user could have declined some scopes. Always read this field and store it. See Partial Grants.

Implementation


Step 5: Call APIs on behalf of the user

Pass the access token as a Bearer token on every request:
The token only permits what the user approved. Calling an endpoint outside the granted scopes returns 403 Forbidden.

Common mistakes

Using an expired code: authorization codes expire in 10 minutes. Exchange them immediately in the callback handler. Skipping state validation: always validate state. Skipping it leaves your users vulnerable to CSRF. Token exchange in the browser: your client_secret must never touch the frontend. All token exchange happens on your server. Assuming all scopes were granted: users can partially approve. Always check the scopes field in the token response. Not storing the refresh token: access tokens expire in 1 hour. Store the refresh token so you can get a new one without the user re-authorizing.

Token Management

How to refresh, store, and revoke tokens

Partial Grants

Handle users approving fewer scopes than requested