Getting OAuth code when Redirect is http://desktop

This thread is now closed to new comments.
Some of the links and information provided in this thread may no longer be available or relevant.
If you have a question please start a new post.
CypherBYTE
1 Post
User

1Posts

0Kudos

0Solutions

Getting OAuth code when Redirect is http://desktop

Hi,

 

First time MYOB API user, long time MS-Access developer.   I am trying to write a simple app that uploads transactions to MYOB after importing them from a POS application. 

 

I have read a lot of documentation here recently but I have hit a snag.    Reading through the Authentication page (here), I get along swimmingly, but then I get to this:

 

"Once the User has authorised your app to access their company files they will be returned to your REDIRECT URL with a ?code= in the URL. You use this code for the next step."

 

How do I get this code?  Where does this ?code= go when the redirect URL is http://desktop ??  I get no error messages, no warnings, no new windows... nothing happens at all.  I also have no .ResponseText.

 

I can put the URL (https://secure.myob.com/oauth2/account/authorize?client_id=etc) into a web browser and it asks for authority but then I get a blank page as a response as soon as I "allow access".

 

I'm probably missing something painfully obvious to others...

 

Sub TestConnection()
    Dim objRequest As Object
    Dim strUrl As String
    Dim strResponse As String

    Set objRequest = CreateObject("MSXML2.XMLHTTP")
    strUrl = "https://secure.myob.com/oauth2/account/authorize?client_id=MYAPIKEY&redirect_uri=http://desktop&response_type=code&scope=CompanyFile"
    
    With objRequest
        .Open "GET", strUrl, True ' <-async - if false, access is denied.
        .SetRequestHeader "Content-Type", "application/json"
        .Send                
        strResponse = .ResponseText
    End With
Debug.Print strResponse End Sub
1 REPLY 1
Tana
MYOB Moderator
43 Posts
MYOB Moderator
MYOB Moderator

43Posts

92Kudos

3Solutions

Re: Getting OAuth code when Redirect is http://desktop

Hi there and thank you for reaching out via the Community forum.

The step you are stuck at is the step where your application must open a new browser window which will host the MYOB Login window for the authorisation.

The redirect portion of this step takes the user back to your application/website once the Authorisation in the separate window has occured. In the backend from this you should recieve an access code which authorises your app to then retrieve an access token & refrsh token and then make calls to the API.

Here is a video showing the full Auth process via the "Postman" application.
https://developer.myob.com/api/accountright/accountright-postman-collection/

And a link to our support document: https://apisupport.myob.com/hc/en-us/articles/360001459455-How-to-Complete-End-User-Authentication-w...

Retrieving the access code is all that is missing in your steps there. Log into yout MY.MYOB account here: https://my.myob.com.au/Pages/Default.aspx and make sure your redirect URI listed here is the same one you are redirecting back to after auth.

If these links are no extra help please feel free to create an AccountRight API Support ticket here: https://developer.myob.com/contact/

Kind regards


Thanks,
@Tana


MYOB API Specialist


MYOB API Support Centre|MYOB App Marketplace|MYOB AccountRight API Endpoint Doc's



Did my answer help?


Mark it as a Solution

Didn't find your answer here?

Try using advanced search to find a post more easily Advanced Search
or
Get the conversation started and make a new post Start a Post