Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > API Authentication >

c# Oauth2 Sample app.

Started by Blair O'Brien -   in API Authentication

To get up to speed with replacing our private app to a new Oauth2 one i was watching the Xero Dev video on youtube about getting started with the .Net SDK.

I have downloaded the latest version of this solution, xero-netstandard-oauth2-starter-dotnet-core-master

I have created the app on the Xero Dev site and copied and pasted the client ID and secret. The callback URI is exactly the same in the json config and on the app created in MyApps.

I run the solution in Visual Studio and the browser opens up with the "Connect to Xero" button. I click the butting and select the "Allow access" to the demo company the next page i get presented with say that "This site can’t be reached. localhost refused to connect."

I have followed the instructions in the video to the letter and can't get this thing working..
Hi,

Make sure you have a postback controller or TCP listener running
 

Henzard Kruger  

I have just tried the Framework 4 version of this starter app, and it worked OK.

Have you tried looking in the F12 developer tools of the browser? I can see in the Network tab that a request goes to https://login.xero.com/identity/connect/authorize/callback?... and it gets back a redirect to https://localhost:44300/Authorization/Callback?...

If it gets the redirect to localhost it's all in the control of your browser again so must be a local problem (assuming the URL is correct).
 

Darren Grayson  

I had worked out what the problem was that I was having with this. Opening the solution in Visual Studio on a Windows PC, it automatically set the app to start with IIS as opposed to XeroNetStandardApp.

Once i changed this, everything worked as it should. Problem solved..
 

Blair O'Brien