Forum Discussion

The_Doc's avatar
The_Doc
Ultimate Cover User
4 months ago

MYOB API access crash - the fixes were simple.

Hi Folks

I will try and keep this succinct - though the evolution of the problem that started with MYOB's back room server/token coders was anything but succinct.

The fixes in the end turned out to be extra-ordinarily simple - easy in hindsight - I have just posted a big email to Tana in MYOB API Analyst - who asked to be kept update on any fixes I found.

All my code to my clients uses MS Access 2019 - not 365 - and it "just works" and has since I built it in 2012 - in retrospective contemplation it was messy code but it worked and the adage "don't fix it if it aint broken" - kept we away from it. 

MYOB broke it the night of 7 Aug 24 - I temp got back online 12 -14 Aug and went offline until 26th Aug and had fixed all my clients by 29th.

If anyone disagrees please say so - what I am trying to do is post a fix for both MS Access 2019 ( not 365 - which has an Edge Browser) and VB.NET VS 2022 MYOB SDK API utility that I got going lastnight.

The Access fix was my own by trial and error the VB.NET fix was directly from a post by Steve_PP, though I modified Steve_PP fix re the extractString as the existing MYOB code worked with a slight mod to the parameters passed on the call. See below - the fixes are so simple.

As I have outlined to Tana I think the single biggest problem was not advising us developers on the night of 7 August when it all went south and really went further south the following Wednesday when MYOB rolled out a fix to fix a fix ( as I am told - the exact details I have no idea as this was 3rd hand).

 

The problem from my perspective - which then enabled the simple fixes below were

My summary may have errors but I think the general gist is accurate: 

MYOB moderator I would love you to fill us in

 

  1. MYOB rolled out updated refresh_tokens the night of 7 August - these had changed in type, scope, length, look and format and not strangely our ExtractToken methods failed - refresh didn't work so we went offline.
  2. At this stage I just thought it was an MYOB token/Server blip and it would right itself before morning ( 2 weeks before my program had acted strangely - it couldn't get a refresh, access_token but by extending the attempts to 5 from 1-2 it fixed the problem - I suspect MYOB was already fiddling
  3. Monday morning 12th I noticed that if I did a browser open GET call using https://secure.myob.com/oauth2/account/authorize?client_id=35p................................sx72cft&redirect_uri=http://desktop&response_type=code&scope=CompanyFile I got back a legit code that was still in the format I was use to - however, I no longer got a json payload and always got an error page and the source code for the page no longer contained the embedded code ( this was the 1st big change) - I kept telling Tana ( who was confused over just this aspect) - that the returned payload had changed.
  4. I manually extracted the access_code - posted a POST to get legit (still accesstoken) the        refresh_token   didn't work.
  5.  I was temporarily back online - but then MYOB rolled out the fix of all fixes and I was dead. The accesscode had now morphed into the new format code=ory........ &scope= .....[all scopes] not just CompanyFile.
  6. It was at this stage that the info was coming about Browser2 (Edgebrowser) Antview2 was being posted on the API forum and pushed to me by MYOB API analayst - yet the info didn't rock/add up - why then was the original open post for an access_code giving an error no matter whether used on Chrome/Edge/Opera/Fox or any other browser - I posted to Tana my confusion.
  7. I then went experimenting with my access code - what if I could extract the code returned from ( not the document returned payload, but the title returned URI??)  - and I experimented with methods in MS Access - and hit gold in 15 minutes - I could get the returned URI with strbody = Me.WebView.Object.Document.documentElement.outerHTML  'old code for returned payload of formatted page to strbody = Me.WebView.Object.Document.URL   'new code 2 Sept 24 - no payload just returned url title - it was that simple 
  8. Change the extracttoken code which was simple, 1 minute fix - and MS Access was back online. Yep that simple.
  9. Then I had to rewrite all my old code - was time anyway - I hadn't realised that the initial access_code post came with a 20 minute access_token & a 7 day refresh_token and kept using refresh_token straight away to get a new access_token and wondering why I couldn't get online - hmm - if it aint broke!!! - that is all fixed now - but now I have to say - if 20 minutes is expired in < 2mins refresh else I might get caught out.
  10. Anyways - lastnight I dug out my old VB.Net 2010/13 utility that is no longer available on MYOBs developers web - it was old - I downloaded the VC# version and VB version but in 2013 I was not anymore than a casual looker at VS 2013 VB & VC# - I got the VB.Net utility working - the code is not disimilar to VBA but VC# was double =dutch to me - the VB.NET utility ran, the VC# didn't - I deleted the VC# - it is gone - if someone has got a copy would appreciate please!!
  11. Since 2013 I am proficient in both languages write in both, have programs running in both but prefer by a mile VB.NET as it is so less demanding on format and really, it doesn't matter which you use.
  12. I dug out my old VB.Net utility from 2013 - updated it to 2022 - .NET framework 4.8 and the MYOB SDK to 6.2024 - and tried to run  it - error!
  13. And last night using partly code that Steve_PP posted and a bit of my own got it going 100% - the fix was as simple as the MS Access fix. 

See attachement

The 1st 2 yellow arrows WebB.Url.AbsoluteURi is Steve_PP fix - the passed parameter in ExtractString(.......,"code=", "&scope")  - is mine - seems that works really nicely with modifying the extraction code.

The 2nd yellow arrows just shuts the browser error page once the access_code is recovered so that you don't really see this page it goes quickly - pretty certain Steve_PP mentioned this as he wasn't sure why the error ( the error is the missing payload that MYOB has removed) - it is irrelevant now - not needed but a MYOB blue in removing I suspect.

 

And that folks is as simple as it gets - the utility runs just fine - though there was another comms error but that may be a msgbox I left in there somewhere in trying to find a solution.

All my clients online files showed - selected one of them - all the item invoices loaded - clicked an invoice and it desplayed perfectly.

 

Tana in MYOB has been given this fix ( Steve_PP contribution advised as appropriate) and I have asked Tana to please keep us ( The developers) advised even if MYOB think they might changed something - hmm - wishful thinking.

 

Finally, it is my opinion ( maybe wishful thinking, hope, dream) that when MYOB finally roll forward, again, the update for the Edgebrowser that it won't change anything and the above fixes will continue to work and we won't need Antview2 (at $350 plus Euro) or WebBrowser2. That this change was not the cause of all the problem - it was MYOB's lack of understanding of the changes that were created and not keeping us advised.

 

The Doc

No RepliesBe the first to reply