Forum Discussion

kjm's avatar
kjm
Trusted Cover User
2 years ago

Is anyone authenticating using the .NET SDK?

I am getting the access code just fine and authenticating using POSTMAN and it is returning the authentication token. I have also build my own oauth class to make the calls to get the access code and then auth token. These methods both work.

 

However when I look at this article https://apisupport.myob.com/hc/en-us/articles/5215765325071-Cloud-Service

it shows to insert the access code in this line  

var tokens = oauthService.GetTokens(OAuthLogin.GetAuthorizationCode(configuration));

 

but that gives me a 400 bad request.

 

Like I said in my own code I retrieve the token just fine and end up doing this instead assigning the token I get to the keystore.OAuthResponse and thisends up working fine

 var 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
                };

but it leads me to belive that the SDK is not working for authentication...have I got this wrong? is anyone using the SDK Authentication successfully by passing the access code in? or is noone using the SDK? have you just built your own clients for accessing the API?

 

Have I got the code wrong? 
I am assuming that the parameter "code" (see screenshot) is referring to the access code. Can someone confirm this please

 

2 Replies

Replies have been turned off for this discussion
  • PhilWherrett's avatar
    PhilWherrett
    Experienced User

    As per the following line in the article:

     

    The function OAuthLogin.GetAuthorizationCode is a helper class created in the samples that illustrates how to create a form that launches the secure.myob.com my.MYOB login page.

     

    However, it appears that the samples no longer exist (or I can't find them).

    • kjm's avatar
      kjm
      Trusted Cover User

      Ah..I see..yes I tried lookinf for it as well and I cannot see it either

      When I went thru the doco there were a lot of 404 so this does not surprise me. Not bagging MYOB but simply pointing out a fact :smileyhappy:

      I ended up writing my own class to extract the auth code and then attempted to insert it and like my post says it does not work. I am "talking" to someone in support at the moment (support is very slow) and they are looking into it

      I know I have got the right auth code as I can use it toretreive the tokens and then assign the token to the SDK and make a valid call