authentication - Xero Public Application Integration With C# -
i want integrate xero c# windows service application. did not find simple code snippet connect xero c#. don't want user interaction while authorising user xero.
i found code below redirects me xero login page authenticate , generates verification code, how can avoid , go ahead because in windows service not have gui enter verification code.
using system; using system.linq; using system.windows.forms; using xero.api.core; using xero.api.example.applications.public; using xero.api.example.tokenstores; using xero.api.infrastructure.oauth; using xero.api.serialization; namespace xerointegrationtest { public partial class form1 : form { public form1() { initializecomponent(); connectxero(); } public void connectxero() { try { // public application sample var user = new apiuser { name = environment.machinename }; string consumerkey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; string consumersecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; var public_app_api = new xerocoreapi("https://api.xero.com/api.xro/2.0/", new publicauthenticator("https://api.xero.com/api.xro/2.0/", "https://api.xero.com/oauth/requesttoken", "oob", new memorytokenstore()), new consumer(consumerkey, consumersecret), user, new defaultmapper(), new defaultmapper()); var public_contacts = public_app_api.contacts.find().tolist(); } catch (exception ex) { messagebox.show(ex.message + ex.stacktrace); } } } }
but generates oauth_problem=permission_denied&oauth_problem_advice=the%20consumer%20was%20denied%20access%20to%20this%20resource
error.
hope me.
Comments
Post a Comment