Murray Brown
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
"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
How do I do this? Thanks
ASKER