Hello,
I am using the Graph api (still testing) to access outlook and I want to let it run in the backend with VB. How can i get the authorization code with VB? In my testing scenario it works fine, if i request the token with VB (2nd Endpoint in V2). But this only works fine with the authorization code that I requested before with my browser (1st Endpoint V2, url: https://login.microsoftonline.com/TENANT/oauth2/v2.0/authorize?client_id=CLIENTID&response_type=...)
How does it work to get the code in the backend? I have tryed something like this, but the authorization fails:
strURL = https://login.microsoftonline.com/TENANT/oauth2/v2.0/authorize?client_id=CLIENTID&response_type=...
strUser= "user@example.com"
strPassword= "XXXX"
Dim objHTTP ' As MSXML.XMLHTTPRequest
If Len(strURL) Then
' Dim base64 As New Base64()
Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
objHTTP.setRequestHeader "Authorization", "Basic " + base64.encode(strUser + ":" + strPassword)
objHTTP.setRequestHeader "Host", "https://login.microsoftonline.com"
objHTTP.open "GET", strURL, False objHTTP.send (strPOSTString) 'Get it.
strReturn = objHTTP.responseText
End If
Set objHTTP = Nothing
Who can help me to get the code with VB?
Thanks!