How To Setup Oauth2 Authentication With Microsoft: Global Support
How To Setup Oauth2 Authentication With Microsoft: Global Support
Authentication with
Microsoft
Global Support
08 2016
Prerequisites
You will require the following items to set up OAuth2 with a Microsoft account:
Your server URL – public or private – is required. Examples https://www.my_server.com or
https://MyServerName.
A Microsoft account that will be used to administer the service. This can be done through following link:
https://apps.dev.microsoft.com. In the following example we will use the mock
account [email protected].
Select a name for your OAuth2 service. It must start with a letter (A-Z or a-z) followed by any
combination of letters (A-Z or a-z), digits or underscores. In the following example, the name Microsoft is
used.
Oauth2 must be configured as a valid authentication method in your Sage X3 nodelocal.js file such as
below:
session: {
timeout: 30, // minutes
checkInterval: 60, // seconds
auth: ["basic", "oauth2"]
}
Click Generate a Password, under Application Secrets. Copy the password to a safe place, such as
a password manager (e.g. KeePass), for reference later in the process:
The name of the service must match the service name chosen earlier (Prerequisites) exactly. The
display name can be chosen freely.
The frames highlighted in red above hold constant values for Oauth2 Microsoft authentication. They
must be populated exactly as shown in the picture above for any Microsoft service:
– Oauth2 server URL without path: https://login.microsoftonline.com
– Path for authorization: /common/oauth2/V2.0/authorize
– Path to get access token: /common/oauth2/V2.0/token
– Scope for Oauth2 requests: User.Read
– URL for requesting user data: https://graph.microsoft.com/v1.0/me
– User field in user name answer: userPrincipalName
Redirect path for Oauth2 server depends on the Sage X3 (Product Update 9) Web Server and the
service name selected earlier (c.f. Prerequisites). If this is editable, it must host the Web Server address
followed by the /auth/oauth2/NAME/loginCallback segment (where NAME is the service name.)
The information in blue (Oauth2 client ID and Oauth2 client secret) corresponds to the client ID
shown and to the password defined in the Client ID for web application section on the Microsoft
service site, on the page that shows the client ID.
Note:
We recommend you use an external identity service such as LDAP or oAuth2 for all users, including
special users that support web service calls. Nevertheless, you will need to adapt your web service
clients to authenticate with oAuth2
If you are using web services published by Sage X3, you can temporarily activate both basic and oauth2
in your nodelocal.js file and configure the special web service users to use basic authentication. This will
allow you to keep your web services in operation while you adapt them for oauth2. Once you have
upgraded your web service clients you should edit nodelocal.js again and only enable oauth2 to tighten
security.
A direct link can also be typed and/or set in your browser favorites to access the Microsoft authentication
directly:
http://www.my_server.com/auth/oauth2/Microsoft/loginStart
When this is done, you are redirected to the Microsoft site to authenticate using your Microsoft account if
this has not already been done. The page appears as follows:
You will be prompted by Microsoft to allow Sage X3 to access the profile when logging in for the first time:
Note: Your authentication will be valid until you log out of your Microsoft account or clear your browser’s
cookies As a result Sage X3 may not need to prompt you to authenticate if your Microsoft login is still valid.