umbraco / Umbraco.Cms.Integrations

MIT License
36 stars 21 forks source link

Connect with Dynamics 365 results in multi tenant error, although TokenEndPoint in appsettings is set to tenant #220

Open remkovb opened 1 month ago

remkovb commented 1 month ago

When trying to connect from the Dynamics Forms data type, after logging in I get following error: (where tenant guid is replaced by [tenant-guid])

AADSTS50194: Application '[tenant-guid]' (name of application) is not configured as a multi-tenant application. Usage of the /common endpoint is not supported for such applications created after '10/15/2018'. Use a tenant-specific endpoint or configure the application to be multi-tenant.

I configured TokenEndPoint this way:
"Integrations": {
                "Crm": {
                    "Dynamics": {
                        "Settings": {
                            ".
                        },
                         "OAuthSettings": {
                          ..
                          "TokenEndpoint": "https://login.microsoftonline.com/[tenant-guid]/oauth2/v2.0/token"                        
                        }
                    }
                }
            }

It seems it tries to connect to /common endpoint instead. So maybe TokenEndPoint from configuration isn't used in code?

Edit: In BaseAuthorizationService I can see this code:

protected const string DynamicsAuthorizationUrl = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize" +
     "?client_id={0}" +
     "&response_type=code" +
     "&redirect_uri={1}" +
     "&response_mode=query" +
     "&scope={2}";

Where common should be replaced by tenant id, in my case.. hmm


This item has been added to our backlog AB#44591

acoumb commented 4 weeks ago

Hi @remkovb , From I can see in your settings, do you try to use your own authorization setup? And not the default Umbraco one? If so, have you tried with the default setup where you just use the instance URL?

"Crm": {
  "Dynamics": {
    "Settings": {
      "HostUrl": "https://[instance].crm4.dynamics.com/",
      "ApiPath": "api/data/v9.2/",
      "Module": "RealTime"
    }
  }
}