AGenius / Xero.Net.OAuth2

.NET Framework version of the Xero.NetStandard SDK it also provides a simple way to get your Xero oAuth2 tokens and wrap the Net-Standard API calls into simpler Synchronous calls
1 stars 0 forks source link

how to "connect"? #20

Closed attilaTM closed 3 years ago

attilaTM commented 3 years ago

Your wrapper seems to be very useful, it makes life easier. I just need to understand exactly how to use it. The code I am trying with, is XeroConfiguration XeroConfig = new XeroConfiguration { ClientID = "EF88A72FCDE941948F74C2D188B83340", CallbackUri = new Uri("http://localhost:8888/callback/"), // Add Scopes this way or see below ////Scopes = new List { Xero.Net.Core.OAuth2.Model.XeroScope.accounting_contacts, Xero.Net.Core.OAuth2.Model.XeroScope.accounting_transactions }, //State = XeroState, // Optional - Not needed for a desktop app codeVerifier = null // Code verifier will be generated if empty };

        XeroConfig.AddScope(Xero.Net.Core.OAuth2.Model.XeroScope.all);
        Xero.Net.Core.API xeroAPI = new Xero.Net.Core.API(XeroConfig);

Till this moment everything is great, xeroAPI is created but it is not connected. xeroAPI.isConnected is false, xeroAPI.Tennants is null, xeroAPI.AccountingApi.Configuration.AccessToken is null. It is not clear how to “connect”, but without that a call like var invoices = xeroAPI.AccountingApi.Invoices(); throws a null reference exception. In the code above I did not hide the ClientID, it belongs to a real test app created on the Xero developer platform, it uses PKCE as it was requested in the "getting started" section in the description. Many thanks in advance for your help. By the way, it would be useful to have a sample app showing how to use your wrapper.

AGenius commented 3 years ago

I created a separate test app here https://github.com/AGenius/XeroAPI2Tests

AGenius commented 3 years ago

The connection step should show a browser popup to authenticate to Xero , make sure this is happening

AGenius commented 3 years ago

I just noticed the readme is missing something

xeroAPI.InitializeAPI();