Freshbooks

Authenticating to FreshBooks

FreshBooks uses the OAuth authentication standard. To authenticate using OAuth, you will need to create an app to obtain the OAuthClientId, OAuthClientSecret, and CallbackURL connection properties.

See below

Connecting to the Classic API

There are two methods you can use to connect to the FreshBooks Classic API, the authentication token specific to your login or OAuth 1.0. The authentication token method is deprecated and will not be supported by FreshBooks in the future.

Using the Authentication Token to Connect to FreshBooks

To connect to FreshBooks using an authentication token, specify the CompanyName and Token connection properties. The token can be found by logging in to FreshBooks and navigating to My Account > FreshBooks API.

Using OAuth to Connect to FreshBooks

OAuth requires the authenticating user to interact with FreshBooks using the browser. The provider facilitates this in various ways as described in the following sections.

Register Your Application

To obtain the OAuth client credentials:

  1. Request Developer Access through FreshBooks, if you have not already done so.

  2. Select My Account > FreshBooks API.

  3. Select the Use OAuth option and enter the application details. The details are displayed to users when they log in to grant permissions to the application. The OAuth consumer secret is displayed.

Note: It may take some time for FreshBooks to approve your registration.

Authenticate to FreshBooks from a Desktop Application

After setting the following connection properties, you are ready to connect:

  • OAuthClientId: Set this to the name of the company you are connecting to. Note that you can also use the CompanyName.

  • OAuthClientSecret: Set this to the consumer secret in your app settings.

  • InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the access token in the connection string.

When you connect, the provider opens the OAuth endpoint in your default browser. Log in and grant permissions to the application. The provider then completes the following OAuth process:

  1. Retrieves the OAuthAccessToken and OAuthAccessTokenSecret and authenticates requests.

  2. Refreshes the OAuthAccessToken when it expires.

  3. Saves OAuth values in OAuthSettingsLocation to be persisted across connections.

Authenticate to FreshBooks from a Web Application

To obtain the access token, set the following connection properties and follow the steps below:

  • OAuthClientId: Set this to the name of the company you are connecting to. Note that you can also use the CompanyName property.

  • OAuthClientSecret: Set this to the consumer secret in your app settings.

To connect to data, set the following connection properties:

  • CompanyName

  • OAuthClientSecret

  • OAuthAccessToken

  • OAuthAccessTokenSecret

Refresh the Token

To automatically refresh the access token when it expires, set InitiateOAuth to REFRESH and set OAuthRefreshToken.

Connect to the Alpha API

Use the OAuth 2.0 authentication standard to authenticate to the FreshBooks Alpha APIs.

OAuth requires the authenticating user to interact with FreshBooks using the browser. The provider facilitates this in various ways as described in the following sections.

Register Your Application

To obtain the OAuth client credentials:

  1. Log into the FreshBooks developers site at https://my.freshbooks.com/#/developer and click Create an App.

  2. Enter information to be displayed to your users when they are prompted to grant permissions to your app.

  3. Specify a redirect URI.

    Set the redirect URI to https://localhost:33333/, or some other similar https url.

    If you are making a Web application, set the Callback URL to a page on your Web app you would like the user to be returned to after they have authorized your application.

Authenticate to FreshBooks

To obtain the access token, set the following connection properties:

  • OAuthClientId: Set this to the name of the company you are connecting to. Note that you can also use the CompanyName property.

  • OAuthClientSecret: Set this to the consumer secret in your app settings.

To connect to data, set the following connection properties:

  • AccountId

  • OAuthClientSecret

  • OAuthAccessToken

  • OAuthAccessTokenSecret

Refresh the Token

To automatically refresh the access token when it expires, set InitiateOAuth to REFRESH and set OAuthRefreshToken.

Last updated