Forum Discussion

Mo_JM's avatar
Mo_JM
Contributing User
20 days ago

Trouble getting Access token

Hi. I'm new to APIs. I know there are articles on how to obtain an Access token, but I'm still stuck. I'm using Rest Fox and trying to POST to https://secure.myob.com/oauth2/v1/authorize/ with the appropriate information, but I get a 502-Bad Gateway error. Being new, I'm not sure if it's the URL, or the credentials, or something else that is wrong. Could someone help please?

  • Hi Mo_JM , you need to encode both the redirect URL and the authorization code itself.

     

    EG:
    code=Wvof%21IAA[[TRUNCATED_FOR_READABILITY]]luF&redirect_uri=http%3A%2F%2Flocalhost%2Fmyob_redirect%2F&client_id=[[MY_API_KEY]]&scope=CompanyFile&client_secret=[[MY_SECRET]]&grant_type=authorization_code

  • Doreen_P's avatar
    Doreen_P
    MYOB Moderator

    Hi Mo_JM,

     

    I get that you're having a 502-Bad Gateway error. Hopefully another developer in the community can get you a response soon, otherwise feel free to reach out to the support team via developer.myob.com.

     

    Best regards,

    Doreen

    • Mo_JM's avatar
      Mo_JM
      Contributing User

      Hi Doreen. I can offer a little more now on my problem, but of course I still don't know why it's happening (I'm new). I'm POSTing via Rest Fox to   https://secure.myob.com/oauth2/v1/authorize

      Header: application/x-www-form-urlencoded

      Body: client_id my id

                client_secret  my secret

                Scope  CompanyFile

                redirect_uri  http://desktop (as per my login)

                Code   the code I got in the authorization step

               Grant_type   authorization_code

       

      When I POST this I get a 502 error. BUT, once when I accidentally had authorisation_code (the Australian spelling) I got a 400 code error. I only get a 400 code if I mistype in this spot. No other mistypes cause this.

      Does this shed any further light on my problem?

       

      • Mike_James's avatar
        Mike_James
        Ultimate Partner

        Hi Mo_JM , you need to encode both the redirect URL and the authorization code itself.

         

        EG:
        code=Wvof%21IAA[[TRUNCATED_FOR_READABILITY]]luF&redirect_uri=http%3A%2F%2Flocalhost%2Fmyob_redirect%2F&client_id=[[MY_API_KEY]]&scope=CompanyFile&client_secret=[[MY_SECRET]]&grant_type=authorization_code

  • I'm getting the same error. 

    This was working fine until Monday and it stopped since yesterday.

     

    R.

  • Any word on this at all. All my integrations have stopped. On the redirect, I'm getting 

    Can’t reach this page
    Make sure the web address http://desktop is correct