Forum Discussion

barameecloudcon's avatar
1 year ago

OAuthTokenIsInvalid

Hi there,

I use OAuth sending post request to get access_token by using client_id, client_secret and refresh token. By doing this, I have received access_token and refresh_tokent back properly. Then I used received access_token, to get companyfile but receveid OAuthTokenIsInvalid.

May you please explain me what I need to check since I use test account which works but client's account does not work

4 Replies

  • The_Doc's avatar
    The_Doc
    Ultimate Cover User
    1 year ago

    Hi barameecloudcon 

     

    Sorry, cannot answer - MYOB are suggesting it is happening to some developers and not others. All my clients went off the air with the same problem - so am handling manual update as I don't want to reprogram my code.

    You are using MYOB's SDK - VC# I presume - though I know and use VC#.Net I never used or even looked at the code to see how it works - I got the VB.Net version going, never got the VC#.Net version going and moved on without trying to analyse.

    Have a look at a reply another post - someone has suggested a temp fix in the VC#.Net code re extinguishing a '== Null '   - has to be VC# - and this may be your temp clue.

    My code is written in VBA and is bespoke.

    Regards Howard

     

  • barameecloudcon's avatar
    barameecloudcon
    Member
    1 year ago

    Thanks for in information The Doc,

    May I know how this actually happen and how to fix? Due to I have this integration with many clients which I have tested with other client accounts. By doing this, it seems work fine for others which can get company file without any issue except this client that I got back with OAuthTokenInvalid. Is this on client side which may have changed configuration causing an issue?

     

    Regards,

    Baramee

  • The_Doc's avatar
    The_Doc
    Ultimate Cover User
    1 year ago

    Hi barameecloudcon 

     

    Read my reply someone else's post - the problem is the MYOB refresh_token is returning a token that is the wrong scope - even if your original scope is "CompanyFile" the refresh gets you a token for an offline file - hence the 'OauthTokenIsInvalid' error.

     

    The workaround - if you are able is force the program to seek a Refresh_Token ( as though you haven't accessed for > 7d) - this comes with a new Refresh_token and also a 20 min access_token which you can use straight away to gain 20 min of access - more if you actually start the access just before the 20 mins is up.

     

    Traditionally you then just refresh with the refresh_token - but don't - it will cause an error - start the cycle again get a new refresh_token and access_token.

     

    The Doc

Looking for something else?

Search the Community Forum for answers or find your topic and get the conversation started!

Community home