KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Fixing AADSTS50194 Error with NetKit OAuth2 Class
PRODUCT: 4D | VERSION: 20 R | PLATFORM: Mac & Win
Published On: July 2, 2025

When using the 4D NetKit OAuth2Provider class to authenticate with Microsoft Azure AD, you might encounter the following error related to tenant configuration.

This happens because the app is registered as single-tenant, but the OAuth request uses the generic /common endpoint, which requires a multi-tenant app or a tenant-specific endpoint.

To fix this, either specify the tenant ID explicitly in the parameters or configure the app to be multi-tenant in Azure Portal.


  • Via 4D Code

  • var $param : Object

    $param := New object()
    $param.name := "Microsoft"
    $param.permission := "signedIn"
    $param.clientId := "YOUR_CLIENT_ID"
    // Add your tenant ID here to avoid the /common endpoint usage:
    $param.tenant := "YOUR_TENANT_ID"
    $param.redirectURI := "http://127.0.0.1:5001/authorize/"
    $param.scope := "openid profile offline_access User.Read Mail.Send"

    // Create the OAuth2 provider instance
    var $oauth2 : cs.NetKit.OAuth2Provider
    $oauth2 := cs.NetKit.OAuth2Provider.new($param)

    $oauth2.getToken()


  • Via Azure

  • Under Authentication choose "Accounts in any organizational directory" to allow Multitenant :