Excel VBA Code to use Desktop, MS Office SSO to login to Fusion SaaS SSO

Viewed 199

As per the link: https://github.com/VBA-tools/VBA-Web/issues/15

We have the option to login to SSO sites using VBA code "WinHttp.WinHttpRequest.5.1" object and "SetAutoLogonPolicy (0)"

We tried to hit the URL: "https://login-XXXX.oraclecloud.com" in VBA with the code mentioned below, we got HTML response with status = 200. When we did hit the IDCS URL which has the SSO configured, we are getting 401 Unauthorized response. Is there any way we can login to Fusion SaaS using SSO of Excel in VBA?

Note:

My user is configured in Azure AD and IDCS for SSO and I am able to login to this environment using my Desktop/MS Office SSO from Web Browser. So no issue in User Management

My Excel shows my user at the title bar. This means that my excel is already logged in to SSO. Hence, I am expecting the SetAutoLogonPolicy to work.

Sub AutoLogin1()

 

Dim winHttp As Object

Set winHttp = CreateObject("WinHttp.WinHttpRequest.5.1")

sURL = "https://login-XXXX.oraclecloud.com"

 

winHttp.SetAutoLogonPolicy (0)

winHttp.Open "POST", sURL

winHttp.setRequestHeader "Connection", "keep-alive"

winHttp.Send

 

Dim success As Boolean

success = winHttp.waitForResponse(5)

   Debug.Print "Status: " & winHttp.Status

   Debug.Print "Status Text: " & winHttp.statusText

   Debug.Print "Response: " & winHttp.getAllResponseHeaders

   Debug.Print "Response: " & winHttp.responseText

 

End Sub
0 Answers
Related