Sign In Try it free

Creating an Integration


This guide assumes you've already done the following:


An integration contains the access tokens which are issued by the 3rd-party service and allow Work-API to access those servies on behalf of a user.

Adding API credentials

In order to make requests on behalf of the developer, credentials must be entered via the Dashboard which allow Work-API to identify as the developer when making calls to the underlying APIs.

When setting up the OAuth credentials on the underlying provider, the Work API OAuth callback URI must be provided as a redirect. Failure to do so will mean users are not able to add integrations.

The Work API OAuth2 redirect URI is:

For information on adding API credentials to the Work API, see Create an Environment

Adding an Integration

Once a set of credentials is stored in the WorkAPI database, the user can then connect their accounts to the system.

Creating the Integration record

The first step is to create an integration via the API.

token = "<user token>"
client =

provider = 'gmail'
media_type = 'email'

integration = proivder, media_type: media_type)
created_integration = client.create_integration(integration: integration)

# => LivilApi::Integration(provider: 'gmail', media_type: 'email', ...)

Authorizing the Integration using OAuth2

The user must explicitly grant permission for WorkAPI to access their account on the underlying service.

The standard process to do this is using OAuth2.

There may be some services which don't support OAuth2 and so the process will be slightly different. That will be covered in documentation for those providers as necessary.

The first step of the authorization process is to send the user to a generated URL which allows the user to approve WorkAPI's access and then pass the access tokens back to the WorkAPI.

The user should be directed to the URI which is returned by this call. They can optionally be redirected automatically using a 302 redirect on the WorkAPI servers.

Once the process is complete, the user is then able to access their data via the WorkAPI.

The access and refresh tokens provided by the 3rd party service are not visible to the developer and held only on the WorkAPI servers.


token = '<user token>'
client =

integration_id = '<ID of previously created integration>' 
return_to = '' # the URL to which the user should be redirected after successful authorization

result = client.auth_integration(integration_id: integration_id, return_to: return_to)

# => { uri: '' }

Authorizing the Integration on Android

Google does not allow authorization of integrations via WebView and so a different route must be taken

A detailed tutorial on integrating Google Sign-In for Android can be found here.

After authorizing the Android app on the device, the serverAuthCode must be passed to the following URL:


Authorization: Bearer <token>
Content-Type: application/x-www-form-urlencoded


A sample Android app for connecting your device with Work-API can be found on Github, here:

The correct scopes must be specified for the integrations you wish to add to your application.

  • Gmail:
    • email
  • Google Calendar:
    • email
  • Google Drive:
    • email

First 50,000 requests are free every month