In MicrosoftRouter the accessTokenURL was hardcoded to https://login.microsoftonline.com/common/oauth2/v2.0/token.
However, you can and should only use common if your app is configured as a multi-tenant application. For single-tenant applications you have to provide it in the accessTokenURL, e.g. https://login.microsoftonline.com/f8cdef31-a31e-4b4a-93e4-89f11e91255a/oauth2/v2.0/token, otherwise it fails with an error like this:
Application '(app ID)' 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."
This PR adds the possibility to change the tenant ID by providing it in MICROSOFT_TENANT_ID env var. If no tenant ID was provided it falls back to common (as before).
Considerations
I would probably have tenantID added to MicrosoftAuth or Microsoft. But these have to conform to FederatedServiceTokens / FederatedService and I couldn't change their required initializers etc.
Add support for Microsoft Tenant ID
In
MicrosoftRouter
theaccessTokenURL
was hardcoded tohttps://login.microsoftonline.com/common/oauth2/v2.0/token
.However, you can and should only use
common
if your app is configured as a multi-tenant application. For single-tenant applications you have to provide it in theaccessTokenURL
, e.g.https://login.microsoftonline.com/f8cdef31-a31e-4b4a-93e4-89f11e91255a/oauth2/v2.0/token
, otherwise it fails with an error like this:This PR adds the possibility to change the tenant ID by providing it in
MICROSOFT_TENANT_ID
env var. If no tenant ID was provided it falls back tocommon
(as before).Considerations
I would probably have
tenantID
added toMicrosoftAuth
orMicrosoft
. But these have to conform toFederatedServiceTokens
/FederatedService
and I couldn't change their required initializers etc.Update
.gitignore
Added .swiftpm folder to
.gitignore