Freshbooks C#.Net Integration

931 views
Skip to first unread message

Paul Reitmeyer

unread,
Mar 29, 2013, 12:35:46 AM3/29/13
to freshbo...@googlegroups.com
I'm looking to develop an integration with Freshbooks and a product called Scribe (www.scribesoft.com), its an integration platform and I'll need to build a RESTful connection to Freshbooks API with C#. I have seen tons of examples for Freshbooks with Ruby/PHP/Java/HTML/etc. but I have yet to see a good example of OAUTH and the Freshbooks API on anything Microsoft.Net (VB.net, C# preferred). Does this exist? I know how to do OAUTH/OData with C#, but I'm really confused on the whole Webhook thing (do I need to use them?). Any guidance at all would be helpful, I'm going to start slow and just try and get an Account Query/Insert/Update working, and then add additional entities from there.
Much appreciated,
-Paul

Anton Nguyen

unread,
Mar 29, 2013, 12:52:00 PM3/29/13
to freshbo...@googlegroups.com
Hey Paul!

There is one library, that I know of, written in C# that's implemented OAuth. You can find it on the helper library page, and its called C# .NET freshbooks-api. I haven't personally worked with this library, and I'm not sure if its been updated recently or not. However, its able to do the entire OAuth dance:
  1. Getting a request token
  2. Getting a verifier back
  3. Getting an access token
  4. Making API Calls
So give it a try, and if you're still having trouble, post here and I'll help you sort it out.

About the webhooks. If your application needs fresh information, for syncing purposes, it would usually have to ping FreshBooks over and over again every few minutes, checking if anything's changed. With webhooks, the need to constantly poll FreshBooks goes away. All you do, is specify a URL on your server, tell FreshBooks to listen to certain events (ie. invoice updated, client deleted, etc...) and when it happens, FreshBooks will post to your URL with useful information such as the invoice_id that was updated. You can then do an invoice.get call, and refresh the data on your server.

Let me know if you have any other questions!
Anton

Michael Webb

unread,
Mar 31, 2013, 10:45:56 AM3/31/13
to freshbo...@googlegroups.com
Hi Paul!

I work with SmartVault (smartvault.com), we authored the C# .NET freshbooks-api Anton recommended below. It should do getting you up an running with the OAuth dance. If you have any problems feel free to give me a shout.

Michael

Robert J

unread,
May 2, 2013, 10:21:57 PM5/2/13
to freshbo...@googlegroups.com
Hi Michael, I tried using the C# .NET freshbooks-api helper library and I am completely lost. I saw on the library's project homepage sample code on how to connect using OAuth 1.0a. It showed the line: 

FreshbooksApi api = new FreshbooksApi("user-account", "developer-account", "optional-oauth-secret");

Let's say if I signed up with Freshbooks with the username johndoe. Would I use johndoe as the developer-account? Inside my johndoe account let's say I created a client with the username janedoe while logged into Freshbooks.com. Would I use janedoe as the "user-account"? Finally, what would I put for the "optional-oauth-secret"? Would that be the Authentication Token that is found under "My Account" > "Freshbooks API"? Or, am I completely off and do these accounts (developer-account and user-account) refer to something completely different?

I apologize for my ignorance and would really appreciate any help.

Thanks!
Robert

Anton Nguyen

unread,
May 7, 2013, 12:14:18 PM5/7/13
to freshbo...@googlegroups.com
Hey Robert,

I might be able to clear some of your confusion. Generally with OAuth, you have a developer account so that you can build your app. Lets say your app looks for people's invoices. Now, when people want to use your apple, they simply authorize your developer-account, to access their data. 

So in terms of FreshBooks, lets say your account is 'https://developer-robert.freshbooks.com'. For the developer-account, you simply provide the subdomain, 'developer-robert'. Now for the user account, it HAS to be a FreshBooks account. So suppose there's a user whose account is 'https://customer.freshbooks.com', you would provide the subdomain, 'customer' for the 'user-account' credential.

Unfortunately, in your particular case, clients on your system cannot use OAuth. Clients don't even have access to the API. What are you trying to build? I might be able to suggest some work-arounds.

Finally, for the 'oauth-secret', Its in your FreshBooks account under 'My Account > FreshBooks API". In the "OAuth Developer Access" section, click on "Use OAuth" and a form will pop up, asking you how you will be using it. We'll then review your form, and grant you access. At at point, the secret will appear in that section.

I hope that answers your questions!
Anton

Robert J

unread,
May 13, 2013, 3:19:06 PM5/13/13
to freshbo...@googlegroups.com
Hi Anton,

Thanks for the response. Basically, we are building a web hosting website. When a client signs up we want to connect to our Freshbooks account, let's say robert-develper.freshbooks.com, and add johndoe to our Freshbooks account. Meaning, we don't want to create an actual Freshbooks account for each of our users, but we simply want to just add them as a client. It seems that perhaps OAuth would not work for us but perhaps the Token-Based Authentication methodology would be more appropriate? Any suggested workarounds would be great. 

Thanks,
Robert

Anton Nguyen

unread,
May 14, 2013, 11:15:37 AM5/14/13
to freshbo...@googlegroups.com
Hey Robert,

If you want to add a 'johndoe' client to your FreshBooks account, you can probably use Token-Based authentication. Then, you can use the 'client.create' api call to create a client with an email, username, password, etc... You can even specify whether or not FreshBooks should notify your client of their credentials. 

Afterwards, they'll be able to log into robert-developer.freshbooks.com and see all their invoices/estimates/etc...  in one spot.

Does that sound like the functionality you wanted? Let me know!
Anton

Robert J

unread,
May 16, 2013, 2:06:59 PM5/16/13
to freshbo...@googlegroups.com
Hi Anton,

Yes, this sounds right. I gave it a try and it works great. Thanks!

alf...@zylun.com

unread,
Jan 12, 2016, 5:30:23 PM1/12/16
to FreshBooks API (not monitored)

Hi Mike;

Good day, I just wanted to know if adding a staff from this app is supported.
Can you show me how?


Regards;
Alfred
Reply all
Reply to author
Forward
0 new messages