Authentication

ExpertFile expects an access token to be included in all API requests to the server in a header that looks like the following:

Create token.

POST https://public-api.expertfile.com/oauth/token

You can find your Client ID and Client Secret in Settings->Integrations inside ExpertFile dashboard. The url is: https://expertfile.com/dashboard/settings/integrations.

Response

  data: {
    accessToken: '<ACCESS CODE>',
    accessTokenExpiresAt: '2024-06-24T16:10:43.457Z',
    client: '<CLIENT ID>',
    user: <ORG ID>,
    scope: true
  },
  success: true
}

Code

const data = new URLSearchParams();

data.append('client_id', '<YOUR CLIENT ID>');
data.append('client_secret', '<YOUR CLIENT SECRET>');
data.append('grant_type', 'client_credentials');

fetch('https://public-api.expertfile.com/v2/oauth/token', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
    },
    body: data
})
.then(response => response.json())
.then(json => {
    const { success, data } = json

    if (success) {
        const { accessToken, accessTokenExpiresAt } = data
        console.log('Token used to sign requests for data', accessToken)
    }

})
.catch(error => console.error(error));

Good to know: You'll be required to sign all requests for data using the token received in this response. Tokens are valid for 30 days, so you may want to store the token for reuse and avoid making repeat calls for a new token.

Last updated