Forum Discussion

CypherBYTE's avatar
4 years ago

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

Replies have been turned off for this discussion