office 365 integration fails with "Specified tenant identifier '######' is neither a valid DNS name, nor a valid external domain


Description

We have configured the office 365 integration and on running the import subscription job it fails. When we navigate to the Oauth profile to test connection we get the following error:

OAuth flow failed. Verify the configurations and try again. Error detail:invalid_request, ####: Specified tenant identifier '####' is neither a valid DNS name, nor a valid external domain.

Cause

On the integration profile, navigate to the rest message record. In here you will see a related link "Get Oauth token"

This has failed with the above message:

OAuth flow failed. Verify the configurations and try again. Error detail:invalid_request, ####: Specified tenant identifier '####' is neither a valid DNS name, nor a valid external domain.

Resolution

This happens with incorrect Tenant ID configuration. While setting up the tenant ID from the office 365 portal ensure that you donot add any additional extensions.

Based on what is populated in the tenantID we automatically create the Oauth record. If this contains extensions that donot match what is configured on the portal you will see this error.