ASP.Net Support
Btw, we really need a Developer Board.
An ASP.Net sample would make a massive difference. Your typical C# sample with OAuth2 does not work for ASP because tokens cannot be kept in memory, and therefore the whole login process requires new access every time. .Net Core does not hold session variables anymore.
I might add, an MVC ASP question has never been successfully answered by MYOB since ODBC was axed. I suppose many intranet developer have given up asking?
The end result is that the C# sample you provide in limiting and does not help with promoting MYOB online connectivity. This may be good for an App, but is useless in an intranet environment.
Can someone please, at minimum, show how ASP.Net (preferable MVC5 web api minimum) can log into our account and maybe show a list of Suppliers so as to show the transition between one page to another whilst maintaining our tokens?
Thank you.
A code sample I have trying to list company accounts is below (MyobOnlineController.cs):
-----------------------------------------------------------------------------------
public ActionResult Index(string code)
{
OAuthMyob.Server.Code = code;
ViewData["Error"] = "";
ViewData["DevPoint"] = "";
try
{
OAuthMyob.Server.Configuration = new ApiConfiguration(OAuthMyob.Setting.Key, OAuthMyob.Setting.Secret, OAuthMyob.Setting.RedirectUri);
OAuthMyob.Server.OAuthService = new OAuthService(OAuthMyob.Server.Configuration);
if (string.IsNullOrEmpty(code) || (OAuthMyob.Server.Keystore.OAuthResponse == null && string.IsNullOrEmpty(code)))
{
string url = string.Format(
"{0}?client_id={1}&redirect_uri={2}&scope={3}&response_type=code",
OAuthMyob.Server.OAuthServer,
OAuthMyob.Setting.Key,
HttpUtility.UrlEncode(OAuthMyob.Setting.RedirectUri),
OAuthMyob.Server.OAuthScope //"CompanyFile" //"la.global"
);
OAuthMyob.Server.OAuthKeyService.OAuthResponse = null;
Response.Redirect(url);
}
else
{
if (OAuthMyob.Server.Keystore.OAuthResponse == null)
{
OAuthMyob.Server.Tokens = OAuthMyob.Server.OAuthService.GetTokens(code);
OAuthMyob.Server.Keystore.OAuthResponse = OAuthMyob.Server.Tokens;
}
var cfService = new CompanyFileService(OAuthMyob.Server.Configuration, null, OAuthMyob.Server.Keystore);
CompanyFile[] companyFiles = cfService.GetRange();
CompanyFile companyFile = companyFiles.FirstOrDefault(c => c.Id == Guid.Parse(OAuthMyob.Setting.CompanyId));
PagedCollection<Account> accounts = new PagedCollection<Account>();
}
}
catch (Exception ex)
{
ViewData["Error"] = ex.ToString();
}
return View();
}
Hi CodeMaker
I’ve moved your post onto our API developers board, so that other developers can share their own insight into your issue.
Having checked with the team who provide support for the API they have advised me that the only code samples they provide are the ones on our Developers website. That said I’ve shared your comments and feedback with them.
If you did have any questions relating to the API, I recommend submitting a request on our API support website. Those requests will be seen to and responded by our team who look after the APIs