Forum Discussion
Hi Steve_PP
Thanks for the above code - I was almost forced to spin up a VB.NET/BV#.NET version thinking all my Access code was now useless - that is the rabbit hole that this MYOB mess has forced upon us.
However, I have got my Access code back online as of last night - and the delay in doing so was the mis-information coming out of API tech( apparently they hadn't been told of the changes made to the server) - however this failed navigation error is not an error, as it turns out (prior to all this change we got a blank page and I could extract the code embedded in the page source) - the returned access code is/was, it seems, embedded in a json payload in the form of a page - this is not happening now - so this error whether using chrome/IE/Edge was not an error - the code was legit - but so far I haven't been able to capture it out of the old webbrowser in Access - however with Antview2 the webbrowser2 Edge it came with a method that enabled easy capture.
I am hoping I can do without Antview2 and capture this code in an ordinary browser.
The Doc
- Steve_PP3 months agoExperienced User
Here's some other info that may be useful. From my reading (not testing,) WebBrowser, available in .NET, runs in IE7 mode by default. There are some reg keys you can use to push it up to IE11 but MYOB have said even that won't be supported soon, so switching to WebView2 makes sense.
After you make the original GET request, after a lot of bouncing around (about 5 calls, which you can see if you put a break on webView2.NavigationStarting in my code) you end up with a return result that includes your chosen redirect URL, e.g. http://desktop, and a bunch of query parameters that include the code you need to POST to get the access tokens. I'm guessing that 'bouncing' now won't happen if you're not using a modern browser (maybe the issue is javascript related?)
The return URL (if using http://desktop) will definitely result in a navigation error because it doesn't point to a valid resource, but is serves the purpose of presenting the code, which you can extract for the next step. I don't remember seeing a page navigation error with the WebBrowser control, probably because the form was closed before it was rendered. With my code, you do get a flash of the error page before the form automatically closes.
I guess if you can't find suitable browser to invoke within your app, you could start an external browser to make the GET request, and make the redirect URL something like http://localhost:1234 and set up a port listener in your app to retrieve the result. Or if that's also a problem, simply provide instructions for the user to copy and paste the redirect URL back into your app so you can extract the code.
- The_Doc3 months agoUltimate Cover User
Hi Steve_PP
Since posting my last I have played around with my trial app I keep on my laptop - originally built before I had any code for my client apps.
But determined I was of keeping the old Access browser I finally found a way of capturing the returned code even though the page errors - prior I could use
Me.WebView.Object.Document.documentElement.outerHTML to capture the page = source code - but that doesn't work now.
I am a bit peeved at having to buy an Antview2 licence which isn't cheap so I am going keep running my code using the std VBA Webviewer - here is what works
Me.WebView.Object.Document.URL
Result = "res://ieframe.dll/dnserrordiagoff.htm#http://desktop/?code=ory_ac_rTxyMWokubBE..........................Sk47H_QJi-IaiieQ4rs6Perq8AZaN6Gv-yTOE&scope=CompanyFile+offline_access+openid&state=887b5f483a0cefc39eee91c2"
And this works fine - the access code is legit - it gives me an access_token and a refresh_token.
I am betting that when MYOB finally switch fully over this will still work - so am using Antview2 on 1 website integration but configuring my other 2 website integrations with MYOB using the above.
The Doc
- Steve_PP3 months agoExperienced User
Ahahahahahaha! Nice work The_Doc
So much pain for so little code that actually needed changing. In .NET, if you change webB.DocumentText to webB.Url.AbsoluteUri and replace ExtractSubstring with the ExtractAuthorizationCode method I posted above you are good to go.
So what's all this about needing modern web browsers then MYOB?
eJuliayou probably want to read this.
Looking for something else?
Search the Community Forum for answers or find your topic and get the conversation started!
Find technical support and help for all MYOB products in our online help centre
Dig into MYOB Academy for free courses, learning paths and live events to help build your business with MYOB.