How do I Connect an Azure Function App to MYOB?

177 Views Asked by At

I am try to connect an Azure Function App to the MYOB API.

I can get it to work running the Azure app from my desktop, but doesn't work when I move it to the cloud.

The published code is -

var developerKey = "YOUR API KEY";
var developerSecret = "YOUR API SECRET";

var configuration = new ApiConfiguration(developerKey, developerSecret, "http://desktop");
var oauthService = new OAuthService(configuration);
var tokens = oauthService.GetTokens(OAuthLogin.GetAuthorizationCode(configuration)); 
var keystore = new SimpleOAuthKeyService();
keystore.OAuthResponse = tokens;

// Get Company Files 
var cfService = new CompanyFileService(configuration, null, keystore);
var companyFiles = cfService.GetRange();

The problem seems to be the line -

oauthService.GetTokens(OAuthLogin.GetAuthorizationCode(configuration)); 

As that function opens the MYOB login page and returns the authorization code via the HTML.

Has anyone been able to connect an Azure function to MYOB?

Thanks!

1

There are 1 best solutions below

1
Narendran Pandian On

Usually there are two ways to get the authorization token: 1) User Login 2) Application Login

Application is registered and their credentials used to access an API is what you are going for.

But what I can see from their documentation is that, they don't have that process. They only have the user flow open, which is very similar to Azure SSO login where it gets access codes and based on it, it gets the token.

User flow should still be fine, if your app is the front end app and the users of the app should have access to MyOB as well.