Connecting to Office365

I’m trying to connect to Office 365. I added a development environment in Azure ( and did all the stupid IDs. The code is directly out of the Chilkat example:

Dim oauth2 As New Chilkat.OAuth2
oauth2.ListenPort = 9995 'this is the redirect url from the Azure portal
oauth2.AuthorizationEndpoint = "" + getT + "/oauth2/v2.0/authorize"
oauth2.TokenEndpoint = "" + getT + "/oauth2/v2.0/token"
oauth2.ClientId = getD
oauth2.ClientSecret = getS
OAuth2.RedirectAllowHtml = kAllowDenyHtml.Replace("<<content>>", kRedirectAllowHtml)
OAuth2.RedirectDenyHtml = kAllowDenyHtml.Replace("<<content>>", kRedirectDenyHtml)
oauth2.CodeChallenge = False
// Important: The offline_access scope is needed to get a refresh token.
oauth2.Scope = "openid profile offline_access"

'start the oauth
Dim OfficeOauthUrl As String = oauth2.StartAuth()
If not oauth2.LastMethodSuccess Then
  Globals.theErrorLog.LogItem("Oauth start: " + oauth2.LastErrorText)
  return false
End If

// Now wait for the authorization.
Dim TimeoutInMS As Integer
While TimeoutInMS < 60000 * 5 And oauth2.AuthFlowState < 3 '5 minute timeout
  TimeoutInMS = TimeoutInMS + 100

However, I get an error message when trying to log in:

What does the Microsoft help at Error AADSTS50020 - User account from identity provider does not exist in tenant - Active Directory | Microsoft Learn want to tell me? What do I need to change?

The app you created may be limited to only people from the same company.
You could change it to allow all tenants.

Is “All Microsoft Account users” not good here?

Does my app need to be visible to users?