I’m trying to connect to Office 365. I added a development environment in Azure (https://portal.azure.com/) 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 = "https://login.microsoftonline.com/" + getT + "/oauth2/v2.0/authorize"
oauth2.TokenEndpoint = "https://login.microsoftonline.com/" + 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 https://outlook.office365.com/SMTP.Send https://outlook.office365.com/IMAP.AccessAsUser.All"
'start the oauth
Dim OfficeOauthUrl As String = oauth2.StartAuth()
If not oauth2.LastMethodSuccess Then
Globals.theErrorLog.DialogErrorProceed(kErrorOauthStart)
Globals.theErrorLog.LogItem("Oauth start: " + oauth2.LastErrorText)
return false
End If
System.GoToURL(OfficeOauthUrl)
// Now wait for the authorization.
Dim TimeoutInMS As Integer
While TimeoutInMS < 60000 * 5 And oauth2.AuthFlowState < 3 '5 minute timeout
oauth2.SleepMs(100)
TimeoutInMS = TimeoutInMS + 100
Wend
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?