Forum Discussion

Phil_Jeffrey_KC's avatar
Phil_Jeffrey_KC
Experienced User
4 months ago

Unsupported browser error

As others have discovered, apps that use the IE browser control, such as VB or VBA apps, no longer work.  There is an Edge Browser control available for VB/VBA apps.  I'm currently trying to get the Edge Browser control to handle the OAuth process, with limited success.  If anyone has any sample code, it would be greatly appreciated.

 

On another note, today I discovered one of my private MYOB apps had switched key/secret with another app.  Not sure if this is related or whether others have encountered the same problem.

  • Just thought I would provide an update on this topic, for partners with Microsoft Access VBA apps that used the WebBrowser (IE) control to handle MYOB's authentication process.

     

    Microsoft has created an "Edge Browser Control" specifically for Access, but this is incompatible with MYOB's authentication process.  Basically you need to provide the control with a pre-defined list of trusted URLs that it can redirect to.  But because the MYOB authentication process returns a different auth code in the URL every time, it is impossible to predict what those URLs will be.

     

    The solution I found was a company who created an ActiveX "wrapper" around the WebView2 component, to make it compatible with Microsoft Access.  The component is located here: https://antview.dev/.  I've done some testing with the 30 day trial, and it works.  The full version is 300 euros (around A$500).

     

    Here is the VBA code for my Access MYOBLogin form, if anyone is interested.  "EdgeBrowser2" is the name of the AntView browser control.

     

    Option Compare Database
    
    Private Sub Form_Load()
    
    Dim strURL As String
    
        MYOB_KEY = GetMYOBKey()
        
        strURL = "https://secure.myob.com/oauth2/account/authorize?client_id=" & MYOB_KEY & "&redirect_uri=http:%2F%2Fdesktop&response_type=code&scope=CompanyFile"
        
        ' the below command is necessary so we can use the OnNavigationCompletedHex event,
        ' as Access doesn't support the LongLong parameter in the OnNavigationCompleted event
        Me.EdgeBrowser2.EventsUseHexadecimal = True
        
        Me.EdgeBrowser2.Navigate strURL
        
    End Sub
    
    
    Private Sub EdgeBrowser2_OnNavigationCompletedHex(ByVal IsSuccess As Boolean, ByVal WebErrorStatus As TxWebErrorStatus, ByVal NavigationIdHex As String)
    
        Dim b As String
        b = Me.EdgeBrowser2.Source
        
        If b Like "*code=*" Then
            MYOB_CODE = Right(b, Len(b) - 21)  ' remove "http://desktop/?code="
            MYOB_CODE = Left(MYOB_CODE, InStr(MYOB_CODE, "&scope=") - 1)   ' remove everything from "&scope=" to the end of the string
            Debug.Print MYOB_CODE
            UpdateMYOBCode MYOB_CODE   ' sub to save the auth code to a table, so it can be used to get the token
            DoCmd.Close acForm, "MYOBLogin"  ' close the login form
        End If
        
    End Sub

     

  • Just thought I would provide an update on this topic, for partners with Microsoft Access VBA apps that used the WebBrowser (IE) control to handle MYOB's authentication process.

     

    Microsoft has created an "Edge Browser Control" specifically for Access, but this is incompatible with MYOB's authentication process.  Basically you need to provide the control with a pre-defined list of trusted URLs that it can redirect to.  But because the MYOB authentication process returns a different auth code in the URL every time, it is impossible to predict what those URLs will be.

     

    The solution I found was a company who created an ActiveX "wrapper" around the WebView2 component, to make it compatible with Microsoft Access.  The component is located here: https://antview.dev/.  I've done some testing with the 30 day trial, and it works.  The full version is 300 euros (around A$500).

     

    Here is the VBA code for my Access MYOBLogin form, if anyone is interested.  "EdgeBrowser2" is the name of the AntView browser control.

     

    Option Compare Database
    
    Private Sub Form_Load()
    
    Dim strURL As String
    
        MYOB_KEY = GetMYOBKey()
        
        strURL = "https://secure.myob.com/oauth2/account/authorize?client_id=" & MYOB_KEY & "&redirect_uri=http:%2F%2Fdesktop&response_type=code&scope=CompanyFile"
        
        ' the below command is necessary so we can use the OnNavigationCompletedHex event,
        ' as Access doesn't support the LongLong parameter in the OnNavigationCompleted event
        Me.EdgeBrowser2.EventsUseHexadecimal = True
        
        Me.EdgeBrowser2.Navigate strURL
        
    End Sub
    
    
    Private Sub EdgeBrowser2_OnNavigationCompletedHex(ByVal IsSuccess As Boolean, ByVal WebErrorStatus As TxWebErrorStatus, ByVal NavigationIdHex As String)
    
        Dim b As String
        b = Me.EdgeBrowser2.Source
        
        If b Like "*code=*" Then
            MYOB_CODE = Right(b, Len(b) - 21)  ' remove "http://desktop/?code="
            MYOB_CODE = Left(MYOB_CODE, InStr(MYOB_CODE, "&scope=") - 1)   ' remove everything from "&scope=" to the end of the string
            Debug.Print MYOB_CODE
            UpdateMYOBCode MYOB_CODE   ' sub to save the auth code to a table, so it can be used to get the token
            DoCmd.Close acForm, "MYOBLogin"  ' close the login form
        End If
        
    End Sub

     

    • The_Doc's avatar
      The_Doc
      Ultimate Cover User

      Hi Phil_Jeffrey_KC 

       

      Thanks for this code - I have sort of used some of it as it isn't performing as you have indicated, notwithstanding, it is a ringinto access so methods and properties may not be exposed correctly.

      By your description - and what I did with the old browser was loop whilst busy ( = loading in th new one). However, the old browser is very different from the new one.

      How did you get the 'OnNavigationComplete' to trigger as this is not available in the events in Access for this browser.

      VB.Net & VC#.Net allows you to programmatically expose an event that isn't listed but I have never done so in Access?

      Otherwise I was just going do a timed loop for say 15 secs -  or

      if webAntview2.Source doesn't contain "code" then keep waiting.

      That  works but it isn't clean.

      Regards The Doc

  • Trish_Lee's avatar
    Trish_Lee
    Experienced User

    Hi Phil_Jeffrey_KC 

    We are using Visual Studio C# apps and trying to urgently upgrade. We have not found a solution to get it to work as yet, however will share any information even though not for VB/VBA.

     

    Thanks

    Trish