# Do not cURL this URL yourself. Redirect or display it to the user.import urllib.parse
import secrets
state = secrets.token_urlsafe(32) # store in session for CSRF verification
params = {
"client_id": "your-client-id",
"redirect_uri": "https://your-app.com/callback",
"response_type": "code",
"scope": "offline_access organization.read",
"state": state,
}
auth_url = "https://oauth.qonto.com/oauth2/auth?" + urllib.parse.urlencode(params)
# Do not requests.get(auth_url) yourself. On your backend, respond to the
# user's request with an HTTP 302 redirect to auth_url, e.g. in Flask:
# return redirect(auth_url)
const crypto = require('crypto');
const state = crypto.randomBytes(32).toString('hex'); // store in session
const params = new URLSearchParams({
client_id: 'your-client-id',
redirect_uri: 'https://your-app.com/callback',
response_type: 'code',
scope: 'offline_access organization.read',
state,
});
const authUrl = `https://oauth.qonto.com/oauth2/auth?${params.toString()}`;
// Do not fetch(authUrl) yourself. On your backend, respond to the user's
// request with an HTTP 302 redirect to authUrl, e.g. in Express:
// res.redirect(authUrl)
$state = bin2hex(random_bytes(32)); // store in session for CSRF verification
$params = [
'client_id' => 'your-client-id',
'redirect_uri' => 'https://your-app.com/callback',
'response_type' => 'code',
'scope' => 'offline_access organization.read',
'state' => $state,
];
$authUrl = 'https://oauth.qonto.com/oauth2/auth?' . http_build_query($params);
// Do not call $authUrl yourself. On your backend, respond to the user's
// request with an HTTP 302 redirect to $authUrl, e.g. in Laravel:
// return redirect($authUrl);
state := generateRandomState() // store in session for CSRF verification
params := url.Values{}
params.Set("client_id", "your-client-id")
params.Set("redirect_uri", "https://your-app.com/callback")
params.Set("response_type", "code")
params.Set("scope", "offline_access organization.read")
params.Set("state", state)
authURL := "https://oauth.qonto.com/oauth2/auth?" + params.Encode()
// Do not http.Get(authURL) yourself. On your backend, respond to the
// user's request with an HTTP 302 redirect, e.g.:
// http.Redirect(w, r, authURL, http.StatusFound)
String state = generateRandomState(); // store in session for CSRF verification
String authUrl = "https://oauth.qonto.com/oauth2/auth"
+ "?client_id=" + URLEncoder.encode("your-client-id", StandardCharsets.UTF_8)
+ "&redirect_uri=" + URLEncoder.encode("https://your-app.com/callback", StandardCharsets.UTF_8)
+ "&response_type=code"
+ "&scope=" + URLEncoder.encode("offline_access organization.read", StandardCharsets.UTF_8)
+ "&state=" + state;
// Do not call authUrl yourself. On your backend, respond to the user's
// request with an HTTP 302 redirect, e.g.:
// response.sendRedirect(authUrl);
require 'securerandom'
require 'uri'
state = SecureRandom.hex(32) # store in session for CSRF verification
params = {
client_id: 'your-client-id',
redirect_uri: 'https://your-app.com/callback',
response_type: 'code',
scope: 'offline_access organization.read',
state: state,
}
auth_url = "https://oauth.qonto.com/oauth2/auth?#{URI.encode_www_form(params)}"
# Do not call auth_url yourself. On your backend, respond to the user's
# request with an HTTP 302 redirect, e.g. in Rails:
# redirect_to auth_url
{
"error": "invalid_grant",
"error_verbose": "The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client",
"error_description": "The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client",
"status_code": 400
}{
"error": "not_found",
"error_description": "Client not found"
}{
"error": "internal_server_error",
"error_description": "Internal Server Error"
}Retrieve an authorization code
This URL must be opened by the end user’s own browser — never called with Postman, curl, or any other HTTP client. Your server only builds the URL string, then either redirects the user to it using an HTTP 302 status code or opens a pop-up with that URL. Calling this endpoint yourself and forwarding the resulting redirect location to the user breaks the CSRF cookie binding tied to the browser session, and causes request_forbidden: No CSRF value available in the session cookie.
Typical integration pattern: the user visits a route on your app (e.g. GET /integrations/qonto/authorize). Your backend builds the authorization URL below and responds with an HTTP 302 redirect to it — the user’s browser then follows that redirect to Qonto. The code samples on this page build that URL only — they never call it.
Retrieves the authorization of the Qonto user i.e. an authorization code that you will be able to exchange for a set of tokens.
- Your app should include a “Connect with Qonto” button which should trigger this endpoint;
If you are triggering this endpoint on the Sandbox environment (https://oauth-sandbox.staging.qonto.co), please make sure to be logged in on the Sandbox web-app first through your Developer Portal account.
If you just want to connect your app to one single organization, you can just send the endpoint URL to the Qonto user from whom you need to get the consent.
- After clicking on your button, the Qonto user will be redirected to Qonto and will have to authenticate;
- (optional) The Qonto will have to select an organization;
- The Qonto user will have to give their consent to your app for the organization they have just selected (or for the organization identified by the
organization_idor theregistration_idquery parameter); - The Qonto user will be automatically redirected back to your
redirect_uri.
# Do not cURL this URL yourself. Redirect or display it to the user.import urllib.parse
import secrets
state = secrets.token_urlsafe(32) # store in session for CSRF verification
params = {
"client_id": "your-client-id",
"redirect_uri": "https://your-app.com/callback",
"response_type": "code",
"scope": "offline_access organization.read",
"state": state,
}
auth_url = "https://oauth.qonto.com/oauth2/auth?" + urllib.parse.urlencode(params)
# Do not requests.get(auth_url) yourself. On your backend, respond to the
# user's request with an HTTP 302 redirect to auth_url, e.g. in Flask:
# return redirect(auth_url)
const crypto = require('crypto');
const state = crypto.randomBytes(32).toString('hex'); // store in session
const params = new URLSearchParams({
client_id: 'your-client-id',
redirect_uri: 'https://your-app.com/callback',
response_type: 'code',
scope: 'offline_access organization.read',
state,
});
const authUrl = `https://oauth.qonto.com/oauth2/auth?${params.toString()}`;
// Do not fetch(authUrl) yourself. On your backend, respond to the user's
// request with an HTTP 302 redirect to authUrl, e.g. in Express:
// res.redirect(authUrl)
$state = bin2hex(random_bytes(32)); // store in session for CSRF verification
$params = [
'client_id' => 'your-client-id',
'redirect_uri' => 'https://your-app.com/callback',
'response_type' => 'code',
'scope' => 'offline_access organization.read',
'state' => $state,
];
$authUrl = 'https://oauth.qonto.com/oauth2/auth?' . http_build_query($params);
// Do not call $authUrl yourself. On your backend, respond to the user's
// request with an HTTP 302 redirect to $authUrl, e.g. in Laravel:
// return redirect($authUrl);
state := generateRandomState() // store in session for CSRF verification
params := url.Values{}
params.Set("client_id", "your-client-id")
params.Set("redirect_uri", "https://your-app.com/callback")
params.Set("response_type", "code")
params.Set("scope", "offline_access organization.read")
params.Set("state", state)
authURL := "https://oauth.qonto.com/oauth2/auth?" + params.Encode()
// Do not http.Get(authURL) yourself. On your backend, respond to the
// user's request with an HTTP 302 redirect, e.g.:
// http.Redirect(w, r, authURL, http.StatusFound)
String state = generateRandomState(); // store in session for CSRF verification
String authUrl = "https://oauth.qonto.com/oauth2/auth"
+ "?client_id=" + URLEncoder.encode("your-client-id", StandardCharsets.UTF_8)
+ "&redirect_uri=" + URLEncoder.encode("https://your-app.com/callback", StandardCharsets.UTF_8)
+ "&response_type=code"
+ "&scope=" + URLEncoder.encode("offline_access organization.read", StandardCharsets.UTF_8)
+ "&state=" + state;
// Do not call authUrl yourself. On your backend, respond to the user's
// request with an HTTP 302 redirect, e.g.:
// response.sendRedirect(authUrl);
require 'securerandom'
require 'uri'
state = SecureRandom.hex(32) # store in session for CSRF verification
params = {
client_id: 'your-client-id',
redirect_uri: 'https://your-app.com/callback',
response_type: 'code',
scope: 'offline_access organization.read',
state: state,
}
auth_url = "https://oauth.qonto.com/oauth2/auth?#{URI.encode_www_form(params)}"
# Do not call auth_url yourself. On your backend, respond to the user's
# request with an HTTP 302 redirect, e.g. in Rails:
# redirect_to auth_url
{
"error": "invalid_grant",
"error_verbose": "The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client",
"error_description": "The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client",
"status_code": 400
}{
"error": "not_found",
"error_description": "Client not found"
}{
"error": "internal_server_error",
"error_description": "Internal Server Error"
}Query Parameters
Unique identifier of your application. Please sign up to the Developer Portal to get one.
Example: "475670cc-e41a-4baa-8eb6-4329af7d1450"
It represents the list of permission that your application is requesting on the user account. It can be a single scope or a list of scopes together. In the latter case, the scopes must be written as a space separated list of values.
Examples:
- Single scope : "offline_access"
- Multiple scopes: "offline_access organization.read payment.write"
Use the offline_access scope if you require a refresh token.
Please refer to the API Reference section of this documentation to find which specific scopes are required for the actions you would like to perform. You will find the list of the available scopes here.
Type of authentication flow. Only code is supported.
It is a security parameter to protect against forgery attacks.
You need to pass a value that is unique to the user authenticating. At the end of the authentication process, you should compare the received state with the one you provided to make sure they are equal.
Example: "this-is-my-unique-value"
If you want to restrict the user to connect to a specific organization, you can pass the organization_id here. If this parameter is present, then the user won't be asked to select an organization during the OAuth flow.
Example: "1acf250c-a068-47fa-ae9d-032b85c148dc"
Starts the OAuth flow with a pre-selected organization, linked to the registration_id obtained during the onboarding flow. If this parameter is provided, then the user won't be asked to select an organization during the OAuth flow.
Example: "a584b060-8c96-488d-8bbb-74f0d3d2803c"
Response
Redirects the user to Qonto in order to get their authorization.
⚠️ Once the user is redirected to your redirect URI, you need to check the received state parameter against the one you provided on the request. If they do not match, you should stop the process as the request might have been forged by a malicious third party.
Was this page helpful?