Forum Discussion
Hi Kruts,
Sorry for the late reply, I have not been monitoring this forum. I have OAuthLogin.cs and OAuthKeyService.cs that I believe were originally included in the C# samples provided by MYOB on their github which doesn't seem to exist any more.
As far as I know, these are unmodified and still work. Hopefully MYOB won't mind me attaching these. Perhaps they could make them accesible to others again.
- Hamishjam3 years agoContributing User
I'm now having issues with the CompanyFileService.GetRange() method. Using:
// Get Company Files var companyFileService = new MYOB.AccountRight.SDK.Services.CompanyFileService(configuration,null,oAuthKeyService); var companyFiles = companyFileService.GetRange();
GetRange() is throwing the following exception:
MYOB.AccountRight.SDK.ApiOperationException: 'Encountered an operation error (https://secure.myob.com/oauth2/account/authorize/)'
Inner Exception:
JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 2, position 1
I'm working in a .NET 6 WPF solution.
- kjm3 years agoTrusted Cover User
Have you got the access token? Hamishjam
I have not used the class that was uploaded by John_Dinning so I cannot comment on whether it works or not but I have built my own class to get the access token
maybe that was why the class was removed from the online sample but like I said I have not tried using it..
If you have the access token then just create a SimpleOAuthKeyService and assign the values from the token to it and you should be able to run the following.
let me know how you get on. If I have time I'll build a test harness and upload it to github for others that are stuck here...seriously considering leaving the .NET SDK and just using RestSharp/HttpClient to access the APIvar keystore = new SimpleOAuthKeyService(); keystore.OAuthResponse = new OAuthTokens { AccessToken = myobTokens.AccessToken, ExpiresIn = int.Parse(myobTokens.ExpiresIn), ReceivedTime = myobTokens.TokenTime, RefreshToken = myobTokens.RefreshToken, Scope = myobTokens.Scope, TokenType = myobTokens.TokenType }; // Get Company Files var cfService = new CompanyFileService(configuration, null, keystore); var companies = cfService.GetRange(); foreach (var company in companies) { System.Console.WriteLine(company.Name); Debug.WriteLine(company.Name); }
- Hamishjam3 years agoContributing User
Thanks for the reply kjm. I have the access tokens and I'm passing them into the SimpleOAuthKeyService.OauthResponse. That side of things is fine. I'm just getting exceptions when trying to fetch the companyfile object with the CompanyFileService from the SDK. I suspect there may be some unexpected json or a breaking .NET 6 change that is yet to be addressed. My next step will be to play with it in an old .NET framework and report it via GitHub I guess.
I'm also leaning towards just pulling the JSON old school style but it would be nice to not have to build that out. MYOB is MIA... Developer site is a jungle of 404's.
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.