How SuiteCRM API v8 authorization code login lets apps act for users
A team building a web or mobile app often needs to read or write SuiteCRM records as the person currently signed in, not as a shared service account. The authorization code grant on SuiteCRM API v8 solves this: the user approves access on a SuiteCRM screen, and the app receives tokens without ever holding the user's password. The app first sends the user to SuiteCRM to approve, then exchanges the one-time code it gets back for an access token and a refresh token. It uses the access token on each API call and uses the refresh token to obtain new access tokens when the old one expires, so the user does not have to sign in again each time.
This grant is different from the client credentials grant covered in the sibling topic. Client credentials gives a back-office system one integration identity, so records changed through it are attributed to that user and its permissions apply everywhere. The authorization code grant keeps each action tied to the individual who approved it, which matters for audit trails and for record-level access rules. Choose it when the answer to "whose access is this?" is the signed-in user. Confirm the approval screen, redirect and token endpoints, token lifetimes and scope names against the SuiteCRM 8 API documentation for the exact version you install, since these details change between releases and should not be taken from this page.
Before building, plan the parts that surround the flow: the OAuth client registration in SuiteCRM, the exact redirect URIs your web and mobile apps will use, where refresh tokens are stored and how they are protected on each device, and how you will revoke a user's session when they leave or change roles. Ask your SuiteCRM administrator which scopes are enabled and which role permissions the signed-in users hold, because the token only grants what the user can already do. Monitor token issuance and failed exchanges from the start, so that unusual refresh activity or a spike in rejected codes is visible before it becomes an incident.
What the SuiteCRM and app environment needs before the flow works
The authorization code flow depends on several pieces lining up before the first sign-in succeeds. Each item below blocks a different step, and a failure in one often looks like a login problem in another. Check them in this order so you can tell which layer is at fault.
Supported SuiteCRM 8 instance
Run a self-hosted SuiteCRM 8 release that your compatibility matrix lists for your stack. The 8.10 list covers PHP 8.2, 8.3 and 8.4, Apache 2.4, MariaDB 10.6, 10.11, 11.4 and 11.8, and MySQL 8.0 or 8.4 on Linux, Unix or macOS. An unsupported PHP or database version can pass the install and then fail token issuance in ways that are hard to trace. Confirm the exact versions against the matrix before you start.
Compatibility matrixHTTPS on the public hostname
Serve SuiteCRM and the OAuth2 endpoints over HTTPS on the single hostname that apps will call. The redirect after approval and the token responses must use the same scheme and host that the client registration records. A mismatch between the hostname in the app and the one SuiteCRM generates produces redirect errors that look like approval failures. Confirm the public URL in the SuiteCRM configuration matches the one clients use.
Authorization header through the proxy
Confirm the reverse proxy forwards the Authorization header to the SuiteCRM application. Many proxies and load balancers strip it by default, and the API then sees every request as anonymous. Test with a bearer token against a single resource before you build the app. The symptom is a 401 on calls that succeeded when hitting the server directly.
OAuth2 key pair in place
Generate the OAuth2 private and public key pair that SuiteCRM uses to sign access tokens, and make sure the web server user can read the private key and the public key is readable where the API expects it. Missing keys or wrong file ownership cause token requests to fail with server errors. Store the private key outside the web root and record who holds it, because anyone with it can mint tokens.
Registered redirect URI for each app
Register an OAuth2 client for each web or mobile app and record the exact redirect URI it will return to, including scheme, host, port and path. SuiteCRM rejects an authorization request whose redirect URI does not match a registered value exactly, so a trailing slash or a different port will stop the flow. Keep one client per app so you can revoke one without affecting the others.
Test user with the right role
Create a test SuiteCRM user whose role grants only the modules and actions the app needs, and sign in as that user during testing. The token carries that user's permissions, so an administrator account hides access problems and overstates what the app can do. Confirm the user can see the records the app will request before you approve the first consent screen.
How the authorization code flow passes between the app, browser and SuiteCRM
The flow starts when a user clicks sign in within the client app, and the browser is sent to the SuiteCRM login and approval screen. After the user signs in and approves access, SuiteCRM redirects the browser back to the app with a short-lived authorization code. The app backend, which holds the client secret, exchanges that code at the token endpoint for an access token and a refresh token, then calls the SuiteCRM API with a Bearer header. Check that the code only passes through the browser redirect, that the exchange happens server to server, and that tokens never reach the browser.
Authorization code flow, with the trust boundary between the browser and the app backend.
Configuring the authorization code client in SuiteCRM 8
This sequence takes a SuiteCRM 8 instance from OAuth2 key setup to a working authorization code flow, where a web or mobile app receives tokens for a signed-in user and can refresh them. Each step ends with a check that confirms the previous step worked before the next one begins.
Generate or confirm the OAuth2 keys
The platform or security administrator confirms that the OAuth2 private and public key pair exists on the SuiteCRM host, is owned by the web server user, and is readable by that user only for the private key. Follow the current API v8 setup steps in the SuiteDocs for your release, because key file names, locations and passphrase handling are version-specific. Done means the token endpoint can be reached and returns a token response to a test request, rather than a server error about missing or unreadable keys.
Create the OAuth2 client with redirect URI and scopes
An administrator registers the calling application as an OAuth2 client in SuiteCRM, entering the exact redirect URI the app will use after approval and the scopes it needs. Keep the redirect URI identical to the one the app sends, including scheme, host, port and path, because any mismatch is rejected during the approval step. Record the client identifier and secret in the app's secret store. Done means the client appears in the admin list with the expected redirect URI and scope set.
Confirm the login method used by the approval screen
The approval screen appears after the user signs in, so the login method decides what the user sees. Confirm whether the instance uses LDAP or SAML, which SuiteCRM selects through the AUTH_TYPE setting, and test sign-in in a private browser window. For SAML, note that the 8.7.0+ implementation does not support IdP-initiated logout or POST binding to the logout service, so ending a session at the identity provider does not end the SuiteCRM session. Done means a test user reaches the approval screen after signing in through the chosen method.
Build the authorization request
The app builds a browser redirect to the SuiteCRM authorization endpoint with the client identifier, redirect URI, requested scopes, response type set to code, and a random state value that the app checks on return. The developer should also consider a PKCE challenge if the SuiteCRM release supports it, and should confirm that in the release notes. Open the request in a browser as a test user, approve it, and confirm the browser lands on the redirect URI with a code and the same state value.
Exchange the code at the token endpoint
The app's back end posts the authorization code, client identifier, client secret and redirect URI to the token endpoint, which returns an access token and a refresh token. The code is single use and short lived, so exchange it immediately and do not log it. Store the tokens server side, not in browser storage for confidential clients. Done means the response contains an access token, a refresh token and an expiry value, and a second use of the same code is rejected.
Call a read endpoint with the access token
The app sends the access token in the Authorization header to a read endpoint, such as a single record the test user can see in the SuiteCRM interface. The record returned should match what that user sees in the browser, because API access follows the signed-in user's module and record permissions. Test with a record the user cannot see as well, and confirm the response is an authorization error rather than data. Done means the permitted record returns and the restricted one does not.
Test refresh and expired token handling
After the access token expires, the app should receive a 401 response on a read call, then use the refresh token at the token endpoint to obtain a new access token. Confirm that the refresh returns a new access token, that the app replaces its stored tokens, and that the old access token is refused. Also test what happens when the refresh token is revoked or the user is disabled, and confirm the app returns the user to sign-in. Done means the app recovers from expiry without asking for a password and fails cleanly when access is withdrawn.
Which SuiteCRM user, scopes and roles the app inherits
This table maps each identity element of an authorization code app to its SuiteCRM counterpart: the signed-in user, the record access that user already holds, the requested scopes and the approval text, and the audit trail. Read it before design sign-off, because the app can never see more than the user it is acting for.
| Element | What the app gets | What to confirm before build |
|---|---|---|
| Subject (signed-in user) | The SuiteCRM user who approves the consent screen becomes the subject of every token the app receives | Confirm that the app is registered against the SuiteCRM user accounts that will actually use it, not a shared service login |
| App user ID field | A column in the app's own user table that stores the SuiteCRM user ID returned for the signed-in person, linking app accounts to CRM accounts | Decide whether the link is created at first sign-in or by an administrator, and how re-linking works when a CRM user is renamed or deactivated |
| SuiteCRM user ID | The stable identifier the app should key on, rather than the username or email, which can change | Verify in your installed version which claim or resource field carries the user ID, and test it with a non-admin account |
| Record access | Every API call is checked against the user's role and team rules, so the app sees only the modules and records that user can already see in the interface | Test with a restricted role; do not assume the app's access matches a broader integration account |
| Requested scopes | Scope names define which API areas the app may call, and they are shown to the user on the approval screen | Confirm scope names against the installed SuiteCRM 8 version before writing them into the client registration, and request only what each feature needs |
| Approval text | The plain-language description of each scope that the user reads before consenting | Have the business owner and the security team review the wording; it is the only disclosure the user gets |
| User without access | An approved app may still call endpoints the user cannot use, so the app must handle authorization errors and hide features the user cannot reach | Design a clear message for users who lack module access, and log those denials for the administrator |
| Audit trail | SuiteCRM records actions taken through the API, so reviewers can see which user the app acted for, subject to the logging your instance has enabled | Confirm with your SuiteCRM version which fields are logged, and add the app's own request log keyed on the same user ID |
Designing the approval screen and the login behind it
The approval screen that appears during the authorization code flow sits behind the normal SuiteCRM login, so the sign-in method you choose decides who can approve access. Whoever can authenticate to SuiteCRM can approve an app to act for their user, which makes the identity source a security decision rather than a login detail. SuiteCRM 8 documents two login options: LDAP, built on the Symfony Security LDAP authenticators and enabled with AUTH_TYPE=ldap, and SAML, built on the nbgrp onelogin-saml-bundle and enabled with AUTH_TYPE=saml. Confirm which option your instance uses, which directory groups or identity provider users can reach the login, and whether your approval policy needs any extra control such as multi-factor sign-in at the identity provider.
The SAML configuration reference states that the 8.7.0 and later implementation does not support IdP-initiated logout or POST binding to the logout service. In practice, signing out at the identity provider does not end the SuiteCRM session, so a user who has left the corporate portal may still hold an active SuiteCRM session in the browser. Test this on your own version before you rely on it, and record the result in your design notes. Ask whether your SuiteCRM session lifetime and your identity provider session lifetime are set independently, and whether either can be shortened for approval traffic.
An app that relies on the SuiteCRM session must plan its own logout and token revocation rather than assuming that signing out elsewhere will clear access. Define what the app does when a user leaves, including discarding stored refresh tokens and calling the revocation path your SuiteCRM setup supports, and confirm that path with your SuiteCRM administrator before go-live. Also decide who can review active grants for each user, because a session that survives an identity provider logout can keep an approved app working until the token is withdrawn.
Protecting codes, client secrets and refresh tokens
The authorization code grant keeps passwords out of the app, but the security of the flow depends on a few controls working together: strict redirect handling, short-lived codes, a secret that never reaches the client, and tokens that can be revoked. Each card below names one control and the failure it prevents, so you can check each one in your own SuiteCRM 8 setup before go-live.
Exact-match redirect URIs
SuiteCRM should send the authorization code only to redirect URIs registered for the client, compared character for character. A loose match, such as a wildcard path or an unregistered port, lets an attacker redirect a user's code to a host they control. Check that each registered URI is the full https address of your app callback, and that no development or staging callbacks remain on the production client.
Single-use, short-lived codes
The authorization code is only useful for one exchange and should expire quickly. If a code can be replayed, anyone who captures it from a browser history, log file or proxy can obtain tokens. Confirm with your SuiteCRM 8 build how long codes remain valid and that a second exchange of the same code fails, then test both during the retest.
PKCE where the client supports it
Proof Key for Code Exchange binds the code to the client that requested it, so an intercepted code cannot be exchanged by another party. Public clients such as mobile and single-page apps depend on it most. Confirm whether your installed SuiteCRM 8 version and your client library support PKCE before you rely on it, and record the answer in your design.
Client secret kept on the backend
A client secret placed in a mobile app or browser script can be extracted by anyone who downloads the app or opens developer tools. Run the code exchange and any use of the secret on your app backend, and keep the secret in a secrets store rather than in source control or build files. Mobile and browser clients should use PKCE without a shared secret, if SuiteCRM supports that for your client type.
Encrypted refresh token storage
Refresh tokens last much longer than access tokens and can mint new access tokens for as long as they remain valid. Store them encrypted at rest in your backend database or a secrets service, never in local storage, cookies readable by scripts, or application logs. Ask who can read the encryption keys and how they rotate.
Revocation when users or apps end
Tokens must stop working when an employee leaves, changes role, or an app is retired. Without a revocation step, an orphaned refresh token keeps access to customer records after the reason for access is gone. Define who triggers revocation, connect it to your identity lifecycle process, and test that revoked tokens are refused by SuiteCRM.
Scopes limited to app needs
Request only the scopes the app uses to read or write specific records, rather than a broad grant that matches an administrator's access. An over-scoped app turns any token leak into full CRM access. Review the scope list during design and again at each change, and map each scope to a business function the app is approved to perform.
Testing the flow end to end and watching token use
Test the authorization code flow as a set of deliberate failures, not only a successful sign-in. Start with the happy path: the user signs in, approves the screen, the app exchanges the code, calls the API and receives data scoped to that user. Then run a denied approval, where the user clicks deny and the app must show a clear message and store nothing. Next, replay a used or expired authorization code and confirm the exchange is rejected and the first grant is not disturbed. Tamper with the state value on the callback and confirm the app refuses it. Force an expired access token to check that the refresh path runs once, stores the rotated refresh token and retries the original call. Finally, remove the user's access in SuiteCRM and attempt a refresh, then make a call as a user without the right module permissions. Each of these should produce a predictable status code and a logged event. Confirm the exact responses against your SuiteCRM 8 version, since error bodies and token behavior are the details most likely to differ between environments.
Log token issuance, refresh and failure events in the application with the user, client identifier, time and outcome, but never the token values themselves. On the SuiteCRM side, review the web server and application logs for requests to the OAuth2 token endpoint and for API calls returning 401 or 403. Alert when those responses rise sharply above the normal baseline for your environment, because a spike can signal a broken client, a revoked user or a credential being replayed. Establish that baseline during testing rather than assuming a number. Also review which applications hold active grants on a regular schedule and revoke any app that no longer has an owner or a current use case. Ask the team responsible for SuiteCRM to confirm which token and grant records are visible from the administration interface and which require direct database queries, because that decides how quickly a revocation can be verified.
Why the code exchange or API call fails and what to check first
This table lists the failures engineers most often hit when running the authorization code flow against SuiteCRM API v8, with the likely cause, the fix and the first check to run. Work down the rows in order when a login or API call breaks, because several symptoms look alike but come from different layers.
| Failure | Likely cause and fix | First check |
|---|---|---|
| Redirect URI mismatch | The redirect URI sent in the authorization request does not exactly match the one registered on the OAuth client. Register the exact scheme, host, port and path, then resend the request. | Compare the redirect_uri parameter in the authorize request with the registered value character by character. |
| Proxy strips the Authorization header | A reverse proxy or load balancer drops the Authorization header, so the API sees an unauthenticated request. Pass the header through and confirm the web server forwards it to PHP. | Send a request with curl through the proxy and log the headers the SuiteCRM host receives. |
| Missing or wrong key file permissions | The web server user cannot read the OAuth private or public key files, so token signing or validation fails. Set ownership to the web server user and restrict read access to the key files only. | Run ls -l on the key files and confirm the owning user matches the PHP process user. |
| Reused or expired authorization code | Authorization codes are single use and short lived. A retry, a double submit or a delayed exchange causes rejection. Exchange the code once, immediately, and restart the flow to get a new one. | Check whether the callback handler exchanges the same code more than once and review the timestamp of the code request. |
| Client secret sent from the browser | The client secret is embedded in JavaScript or a mobile app bundle, so anyone can extract it. Move the code exchange to a server-side component that holds the secret and keep public clients on the PKCE model the SuiteCRM setup supports, after you confirm that support. | Search the front-end source and built app package for the client secret string. |
| User without role access gets empty results | The token is valid, but the user's SuiteCRM roles do not grant view rights on the module, so list calls return no records instead of an error. Grant the role or test with a user who has the right access. | Compare the user's role assignments for the module with the expected access, then repeat the call as an administrator to separate permission from token problems. |
| Access token used after expiry | Access tokens expire, and calls made with an old token fail with an authorization error. Refresh the token with the refresh token before the call, and rotate the stored refresh token each time you receive a new one. | Decode the token's expiry time and confirm the client refreshes before making calls. |
| SAML session persists after IdP logout | With SAML sign-in on SuiteCRM 8.7.0 or later, logging out at the identity provider does not end the SuiteCRM session, and IdP-initiated logout is not supported. Revoke tokens and end the SuiteCRM session through the application logout path as part of your app's logout flow. | Sign out at the identity provider, then call a protected endpoint with the existing token and confirm whether it still succeeds. |
What a SuiteCRM authorization code integration costs and takes
What drives the cost and duration of a SuiteCRM authorization code integration?
The main drivers are how many applications need user-level sign-in, how many distinct user journeys the integration must cover, and how much of the SuiteCRM side is already in place. A single web app that signs users in and reads their own records is a much smaller job than a web app plus a mobile app, each with different redirect URIs, scopes and token handling. Other factors include whether the SuiteCRM 8 instance already has working OAuth2 keys and URL rewriting, how many modules and fields the app reads or writes, whether custom endpoints are needed, and how much security testing the client requires before launch. Ask any provider for a quote built from a written scope that lists each app, each user journey, each module touched and each environment that must be covered. The quote follows from that scope, and DeployOpen does not publish a price list.
Can our in-house team build a SuiteCRM authorization code integration without a partner?
Yes, a team with solid OAuth2 experience and access to a SuiteCRM 8 staging instance can build it, and many do. The harder parts are usually outside the code: getting the SuiteCRM server configured correctly, confirming that the Authorization header reaches PHP through any reverse proxy, managing key files and permissions, and deciding how sessions and refresh tokens are stored in the app. Teams without recent SuiteCRM 8 experience often spend most of their time learning the platform rather than writing the flow. A useful test is whether someone on the team can explain the redirect URI rules, the token lifetimes, the revocation path and the logging that would show a misuse. If the answer is no for any of these, a partner can either build the integration or review the team's build before it reaches production.
What does the client need to provide for the integration work?
The integration needs several inputs from the client before work starts. Most important are a staging SuiteCRM 8 instance that matches production closely enough to test real permissions, and test user accounts with the roles each user journey will use, so access rules can be checked with more than one profile. The team also needs the exact redirect URIs for each app and environment, the list of scopes or modules each app needs, and a decision on who owns the OAuth client registration. A security review is normally part of launch, so the client should name the reviewers and the evidence they expect. Confirm with your SuiteCRM administrators how the platform is hosted and which proxy sits in front of it, because that determines the header and rewriting checks.
How does an authorization code integration differ from a client credentials integration?
The authorization code grant acts on behalf of a named SuiteCRM user who signs in and approves the app, so the app sees only what that user may see. The client credentials grant, covered on its own page, authenticates a back-office system as itself, usually through a dedicated integration user with a scoped role. That difference changes the work. An authorization code integration needs a sign-in redirect, an approval screen, a code exchange on the server, secure storage of refresh tokens per user, and a way to revoke a single user's access. A client credentials integration needs fewer moving parts but puts more weight on scoping one integration user tightly and rotating its secret. The two can coexist in the same SuiteCRM instance, and most programs with both web users and back-office jobs build both.
Does moving from SuiteCRM API v4.1 to v8 change the authorization code work?
Yes, it adds work and changes the design. API v4.1 uses session-based logins, so an existing client may pass credentials or session identifiers in ways that do not map onto OAuth2. A v8 integration needs the authorization code flow, token handling, and a rewrite of each call into the JSON API resource model. Because SuiteCRM 8.10.2 restricts queries on the v4 API, a legacy client may already behave differently, so the team should test old clients alongside new ones while both run. Plan for a parallel period in staging, record which legacy calls each business process depends on, and make sure the new integration's user permissions match what the old integration allowed. The migration page for this move covers the specifics in more detail.
What recurring work follows launch, such as key rotation, upgrades and token monitoring?
Launch is the start of recurring work, not the end. Signing keys and client secrets need a planned rotation schedule, and the rotation steps should be rehearsed in staging. SuiteCRM 8 minor releases arrive roughly every eight weeks, according to the SuiteCRM LTS page, and each upgrade should be retested against the integration because API behavior and permissions can change. Patch releases contain only security and bug fixes, but they still need staging tests. Token monitoring means watching failed code exchanges, refresh failures, unusual token volumes and revocations, and deciding who reacts to each alert. Ask any partner whether ongoing support, upgrades and testing are offered as a retainer, and what the written scope for that retainer covers.
Is a security review needed before launching an authorization code integration?
A security review is strongly advisable because the integration holds user tokens that can read and change CRM records. The review should cover redirect URI validation, state and PKCE handling where the app type supports it, how refresh tokens are stored and encrypted, token lifetimes, logout behavior, and whether a stolen token can be revoked quickly. It should also test that each user only reaches records their SuiteCRM role allows. DeployOpen runs security testing of applications and APIs, and can test the integration against a written test plan. Any testing result is a finding report, not a certification, so your compliance team should confirm what evidence its own assessment requires.
How DeployOpen works on this
DeployOpen plans and builds the SuiteCRM API v8 authorization code flow inside your own infrastructure, so your SuiteCRM instance, OAuth2 settings and client registrations stay under your control. Engagements start with a written scope covering the apps, user roles, token lifetimes and monitoring your team needs, and the work ends with documented handover to your engineers.
How we scope
- We confirm which web and mobile apps will sign users in and which SuiteCRM modules and actions each app needs.
- We record the redirect URIs, approval screen wording, scopes and refresh token rules in a written scope before build starts.
- We agree in writing which SuiteCRM instance, environment and hosting your team provides, and what DeployOpen will test on staging first.
How we build
- We configure the OAuth2 keys, Authorization header handling and rewrite rules so the authorization endpoint and token exchange work behind your proxy.
- We implement the authorization request, code exchange and refresh token storage in each client, keeping passwords out of the app.
- We test sign-in, denied approval, expired codes, revoked refresh tokens and a user without the right role against your staging instance.
How we hand over
- We deliver a runbook covering client registration, redirect URI changes, key rotation and how to revoke a single app's access.
- We document the token monitoring checks, including refresh failures and unusual token issuance, and where your team reads those logs.
- We walk your engineers through the code, configuration and test cases so your team can change the integration after handover.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers, which can cover SuiteCRM minor release checks for the integration.
- We can retest the integration after each SuiteCRM upgrade or security fix before your team moves it to production.
- Ask any quote to state what is one-time build work and what recurs under a retainer, and who owns each part of the work.

