Thank you for visiting our Partner Zone. This area is an exclusive space for MYOB Partners. Find out how to Partner with MYOB.
Hi there @Henzard,
In this set of code the exRefresh exception should contain a little more information about the error including an 'errors' field. I'd recommend looking into that variable with your debugger to figure out what the error is.
If you're still having trouble, can you share some screenshots of your debugging to the support team via email@example.com and we can take a closer look there.
We createted a desktop app and need the login to persist over time we really need some help with the code. We are saving the auth token in a DB as a json serialized token and then load it up before doing a trasaction. When it expires we renew it but for some reason it need to do a fresh login every few days. Can someone please help.
'Initialising the Connection
myConfiguration = New ApiConfiguration(DeveloperKey, DeveloperSecret, "http://desktop")
myOAuthKeyService = New OAuthKeyService()
'Loading from the DB
Dim authTokens As New OAuthTokens
If (mobjConfig.MYOBToken IsNot Nothing AndAlso mobjConfig.MYOBToken.Length > 0) Then
authTokens = Newtonsoft.Json.JsonConvert.DeserializeObject(Of OAuthTokens)(mobjConfig.MYOBToken)
'Setting the Token
Dim oauthService As New OAuthService(myConfiguration)
myOAuthKeyService.OAuthResponse = authTokens
'Check if it's Expired
If myOAuthKeyService.OAuthResponse.HasExpired = True Then
Dim _oauthService As New OAuthService(myConfiguration)
Dim _tokens As New OAuthTokens
Dim _bolError As Boolean = False
'Try and refresh tokens first ...
_tokens = oauthService.RenewTokens(myOAuthKeyService.OAuthResponse)
_bolError = False
Catch exRefresh As Exception
_bolError = True 'How do I prevent This ???
'If it does not refresh create a new token
If _bolError = True Then
_tokens = oauthService.GetTokens(OAuthLogin.GetAuthorizationCode(myConfiguration))
_bolError = False
Catch exNewToken As Exception
_bolError = True
myOAuthKeyService.OAuthResponse = _tokens
Dim strTokens As String = JsonConvert.SerializeObject(_tokens)
mobjConfig.MYOBToken = strTokens
Remember I consult on a per hour basis. Contact me if your need me to fix the problem. $45 per hour.
We can do a 30 min free consultation via Skype.
Certified Advisor and Full Stack developer
Picahoo cc - 0711304241 - firstname.lastname@example.org
Skype: henzard, Gtalk: email@example.com
Quality is remembered long after the price is forgotten
I abide by the 3 message rule. After 3 messages we skype.