Oauth2 authentication for Web services

This article describes how to authenticate a Web Service call with OAuth2. This authentication method is the only one available to connect to the Online version of Sage X3. You can also use it on-premise, typically if you already use an OAuth2 provider to authenticate users.

Enabling OAuth2 authentication

Two steps are necessary to enable OAuth2 authentication:

First, you need to enable it in your server's nodelocal.js configuration file. This is done in the session section, which should look like:

javascript
    session: {
        // interactive session timeout (minutes).
        timeout: 20,
        // more session settings ...
        // ...
        // authentication modes
        auth: ["oauth2"],
    },
In this configuration only oauth2 is enabled. You can enable several modes, by separating them with commas. For example: auth: ["basic", "oauth2"]. As we want to use web services, the bearer option is also mandatory, so the auth entry should at least look like:
javascript
    session: {
        // ...
        // authentication modes
        auth: ["oauth2","bearer"],
    },

The next step is to configure a user on behalf of whom the web service calls will be executed. This user must be configured with OAuth2 authentication and must be mapped to a Sage X3 user with an appropriate security profile. See the user administration documentation for details.

Calling a Web Service with OAuth2 authentication

When the web service calls the platform, a bearer token must be provided. This bearer token is obtained through an dedicated URL.

Web Services overview