Forum Discussion

DavidK3's avatar
8 months ago

Cannot get Authentication to work on Windows Forms Desktop app

I am struggling to get through Authentication.  Can someone please help me.

I am writing a Window forms desktop application which needs to interface with MYOB (cloud) to create contacts and raise invoices.

 

I cannot get past the Callback.   I am using the Myob AccountRight API SDK.

 

I have been unable for support to show me a working example of such a call back.  I have tried so many combinations.  Here is my code (is VB .net - but C# is also ok) using 

 

Call back is registered appropriately

My code is as follows:

Dim configuration = New ApiConfiguration(clientid, clientsecret, redirecturi)

Dim oauthService = New OAuthService(configuration)

Dim logina As New OAuthLogin

Dim respstring As String = logina.GetAuthorizationCode(configuration)

I get the myob login screen.

I get the 2 factor authentication screen.

Then it transfers control to my callback. What was the callback supposed to do?

My variable “repstring” returns an empty string. I know it is supposed to be the code to be passed to the outhService.GetTokens

 

I have tried saving it with Javascript in the page - but all i get is "java script errors" - even though the callback works in a browser.

 

That is where I am up to now.

 

This is why I asked for an example of the callback html – so I could see what it was supposed to do – so I could do it - in my setting

 

Any assistance will be greatly appreciated.

4 Replies

  • Isaiah_C's avatar
    Isaiah_C
    MYOB Moderator
    8 months ago

    Hi DavidK3,

     

    Hopefully another developer in the community can get you a response soon, otherwise feel free to reach out to the support team via developer.myob.com.

     

    Regards,

    Sai

  • I reported to support.  They indicated that they could not help me.  After several interactions, support indicated they had no examples - and did not know how to help me.

  • Mike_James's avatar
    Mike_James
    Ultimate Cover User
    8 months ago

    Hi DavidK3 , regular support staff won't be able to help you ; you need to contact MYOB API support by lodging a ticket here (various information is required):

    Submit a request – Support for the MYOB family of SME product APIs

     

    There are many articles here:

    Authentication, OAUTH and Authorization – Support for the MYOB family of SME product APIs

     

    Also recommended:

    Error Connecting 3rd Party App To MYOB 16-08-2024 – Support for the MYOB family of SME product APIs

     

    Changes in the auth API – Support for the MYOB family of SME product APIs

    The (truncated) value returned to your redirect URL will look something like this (you need to extract the highlighted section, other sections are explained in the above link):

    http://desktop/?code=ory_ac_zTSXStega...Bel15h9uT8UUnc&scope=CompanyFile+offline_access+openid&state=fee7456fa62aef5f5ed486b6

     

    Also note other users have provided code examples, eg:

    C# WebBrowser -> WebView2 solution | MYOB Community

     

     

     

     

     

  • The_Doc's avatar
    The_Doc
    Ultimate Cover User
    7 months ago

    Hi DavidK3 

     

    Have you sorted your problem - Mike James gave some good pointers!

    Likely I can help though most of my apps are based on MSAccess and this is really easy to fault find during development.

     

    However I did then create a vb.net and vc.net test app successfully get my codes after the MYOB token server crash - reasoning - so I can sort for myself the problems.

    Likely you are getting something back on your callback but not looking in the right place - as of the crash it is no longer embedded in the returned page but the returned url. 

     

    The red herring re the requirement for you to use a webbrowser2 was just that - a red herring - it wasn't the problem. 

    All my Access apps run perfectly without using a WebBrowser2.

     

    Interestingly, XERO token codes creates an error in my MS Access trial app as "this browser is outdated" - but if I set errorflag=true to turnoff warning - I still get my codes without problem.

     

    Regards

     

    The Doc