Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

ASP.net VB.net problem with API after publishing

Hi

I use the following VB.net code to authenticate against the Xero API. It worked fine on my local machine
but I published the site and changed the post back url from my local machine to that of the published site and it doesn't work

    Protected Function XeroAuthenticate(inpage As Page, authpagereturnedauthentication As Boolean, incode As String) As XeroCoreApi
        ' This procedure will return w working XeroCoreApi if successful and nothing otherwise
        ' Set client secrets for general use and then load any override ones from the web.config file
        Dim myxeroconsumer As New Consumer("xxx", "yyyy")
        Dim myxerouser = New ApiUser() With {.Name = "mxx@yahoo.com"}

        ' If user defined ID and Secrets exist then use those instead
        If Not System.Configuration.ConfigurationManager.AppSettings("XeroAPIClientId") Is Nothing Then
            If Not System.Configuration.ConfigurationManager.AppSettings("XeroAPIClientSecret") Is Nothing Then
                If System.Configuration.ConfigurationManager.AppSettings("XeroAPIClientId").ToString <> "" Then
                    myxeroconsumer = New Consumer(System.Configuration.ConfigurationManager.AppSettings("XeroAPIClientId").ToString, System.Configuration.ConfigurationManager.AppSettings("XeroAPIClientSecret").ToString)
                End If
            End If
        End If

        ' Define Page Call Information
        'Dim myxerocallbackurl = "http://localhost:62054/Default.aspx"
        Dim myxerocallbackurl = "http://groundxero.azurewebsites.net/Default.aspx"
        Dim myxeromemorystore = New MemoryAccessTokenStore()
        Dim myxerorequestTokenStore = New MemoryRequestTokenStore()
        Dim myxerobaseapiurl = "https://api.xero.com"

        ' Authenticate with Xero
        Dim myxeroauthenticator As New PublicMvcAuthenticator(myxerobaseapiurl, myxerobaseapiurl, myxerocallbackurl, myxeromemorystore, myxeroconsumer, myxerorequestTokenStore)

        If authpagereturnedauthentication = False Then
            ' Redirect to the authentication page
            Dim requri As String = myxeroauthenticator.GetRequestTokenAuthorizeUrl(myxerouser.Name)
            If requri <> "" Then Response.Redirect(requri, True)
            Return Nothing
        Else
            ' Validate token using querystrings that have been returned from the authentication process
            Dim myxerotoken As IToken = myxeroauthenticator.RetrieveAndStoreAccessToken(myxerouser.Name, Request.QueryString("oauth_token").ToString, Request.QueryString("oauth_verifier").ToString, Request.QueryString("org").ToString)
            If Not myxerotoken Is Nothing Then
                Dim myxeroapi As New XeroCoreApi("https://api.xero.com", myxeroauthenticator, myxeroconsumer, myxerouser)
                Return myxeroapi
            Else
                Return Nothing
            End If
        End If
    End Function

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ron Malmstead
Ron Malmstead
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Murray Brown

ASKER

Hi. So with error handling I get this error oauth_problem=parameter_rejected&oauth_problem_advice=Callback%20url%20is%20not%20in%20the%20registered%20callback%20domain
"if you had to register any DLL's to your machine to get this working, you would also have to do so on the server"
How do I do this? Thanks