# 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.&#x20;

See below

### Connecting to the Classic API <a href="#connecting-to-the-classic-api" id="connecting-to-the-classic-api"></a>

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 <a href="#using-the-authentication-token-to-connect-to-freshbooks" id="using-the-authentication-token-to-connect-to-freshbooks"></a>

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 <a href="#using-oauth-to-connect-to-freshbooks" id="using-oauth-to-connect-to-freshbooks"></a>

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 <a href="#register-your-application" id="register-your-application"></a>

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 <a href="#authenticate-to-freshbooks-from-a-desktop-application" id="authenticate-to-freshbooks-from-a-desktop-application"></a>

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 <a href="#authenticate-to-freshbooks-from-a-web-application" id="authenticate-to-freshbooks-from-a-web-application"></a>

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 <a href="#refresh-the-token" id="refresh-the-token"></a>

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

### Connect to the Alpha API <a href="#connect-to-the-alpha-api" id="connect-to-the-alpha-api"></a>

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 <a href="#register-your-application" id="register-your-application"></a>

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  <a href="#authenticate-to-freshbooks-from-a-web-application" id="authenticate-to-freshbooks-from-a-web-application"></a>

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 <a href="#refresh-the-token" id="refresh-the-token"></a>

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.appstrategy.com/apprules-r-documentation/platform/platform-features/system-settings/data-sources/connection-settings/accounting/freshbooks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
