# Installation (OAuth)

## Overview

Rippling integrations rely on OAuth 2.0, in which Rippling is the server and your application is the client. At a high-level, Rippling will send the user to your redirect URL with a `?code=<xxx>` parameter when they install your application in Rippling. This provides the authorization that your application will utilize to exchange for access and refresh tokens.

## Requirements

To understand the installation flow requirements expected from apps in the Rippling App Shop, see our [Partner Requirements](https://developer.rippling.com/documentation/developer-portal/getting-started/requirements).

## Installation flow

To begin, navigate to your Login URL and then navigate to your App Shop Listing URL as your app will not yet be discoverable from the App Shop.

**Please use the following URLs for your apps:**

| **Purpose** | **URL** |
| --- | --- |
| Login URL | [https://app.rippling.com](https://app.rippling.com/) |
| App Shop Listing URL | [https://app.rippling.com/app-shop/app/{APPNAME}](https://app.rippling.com/app-shop/app/%7BAPPNAME%7D) |
| App Authorize URL | [https://app.rippling.com/apps/PLATFORM/{APPNAME}/authorize](https://app.rippling.com/apps/PLATFORM/%7BAPPNAME%7D/authorize) |
| API Base URL | [https://api.rippling.com](https://api.rippling.com/) |
| API Token URL | [https://api.rippling.com/api/o/token/](https://api.rippling.com/api/o/token/) |

  

#### Rippling-initiated app installation flow diagram

![installation1](https://developer.rippling.com/assets/images/installation1-b2814c72f6e6e0a8e306c7272d027526.png)

#### Partner-initiated app installation flow diagram

![installation2](https://developer.rippling.com/assets/images/installation2-e739c6382b2a59eaba66ef78d545dba3.png)

  

### Initial redirect

As you go through the setup flow, you will be redirected to the redirect URL that you configured in the **Default Redirect URL** field in your app listing. The following query parameters will be present in the redirect:

| Redirect Query Parameter | Description |
| --- | --- |
| code | OAuth code that can be exchanged for an access token. |
| buy | A boolean value based on whether the user indicated they are purchasing a new account, or connecting an existing account. |
| redirect\_uri | The URL on Rippling that the user should be sent back to once the OAuth setup is done. |

> **Note:**
> **Please note:** Rippling will only use redirect URIs that have already been configured in your app. Rippling will not redirect to any URL that is passed as a parameter unless it has been configured as an additional redirect URL in your app listing.

Using the code value, your server will be able to get an access token from Rippling.

> **Note:**
> Once the user has been redirected from Rippling to your application, the authorization code is valid for 300 seconds. The authorization code must be used to redeem an access token within 300 seconds of the code being issued. If an access token is not redeemed with this authorization code by then, the user will need to Redirect from Rippling again.

Rippling will redirect to your redirect URL with an authorization code. The redirect will look like this:

```text
https://oauth.pstmn.io/v1/callback?code=kThqQg24SmDr3Z3XV6oo2CgpC03ysS2M&redirect_uri=https%3A%2F%2Fapp.rippling.com%2Fapps%2FPLATFORM%2FPortalTest%2Freturn&buy=false
```

-   The `redirect_uri` is the URL that you must return the user to in Rippling to complete the app installation flow.

> **Note:**
> The authorization code should be not be grabbed directly from the URL link after the redirect. It should be extracted using server-side code (outside of Rippling) to securely capture and handle the authorization code.

If you need to quickly get another authorization code with your test company, you can go directly to the Redirect URL for your app (replace `INSERTAPPNAME` with your app name) and then click the **Continue** button:

```text
https://app.rippling.com/apps/PLATFORM/INSERTAPPNAME/redirect
```

When the user is redirected from Rippling to your app, that user should then sign in to the app. This allows you to identify the account and associate the code with their account. The redirect URL that you receive from Rippling is where you should redirect the user back to following the user signing into the application.

### Retrieving an access token

To retrieve the access token, your server will need to make a POST request to the API Token URL. The POST request should include a basic auth header with base64 encoded `clientid:clientsecret`, along with the following parameters:

| Auth Query Parameters | Description |
| --- | --- |
| grant\_type | authorization\_code |
| code | OAuth code that was sent in the redirect. |
| redirect\_uri | Your redirect URL. This must match the redirect URL you had provided to Rippling. |

**Example request:**

```text
curl "https://api.rippling.com/api/o/token/" -X POST -H "Authorization: Basic REDACTED" -F "grant_type=authorization_code" -F "code=INSERTAUTHORIZATIONCODE" -F "redirect_uri=https://example.com"
```

-   The `REDACTED` should be replaced with Base64 encoding of the `client_id:client_secret` string in the request header.
    
-   The `INSERTAUTHORIZATIONCODE` should be replaced with the authorization (OAuth) code that Rippling returns in the `code` parameter after the redirect from Rippling to your application .
    
-   The `https://example.com` should be replaced with your **redirect URL** that has already been configured in your Rippling app.
    

**Example response:**

```json
{
  "access_token": "REDACTED",
  "token_type": "Bearer",
  "expires_in": 129600,
  "refresh_token": "REDACTED",
  "scope": "employee:workEmail employee:name"
}
```

When you receive an access token from Rippling, the payload will also include an `expires_in` output. The `expires_in` value is based in seconds and informs you of when your access token will expire. For example, if your access token response includes `expires_in: 129600` then this means the access token you received has a duration of 129,600 seconds.

Access tokens grant access to Rippling APIs for each company. One Access Token will give access to one Rippling Company. So if twelve Rippling companies have installed your app, then twelve Access Tokens will need to be used.

### Mark app as installed

After the installation flow is completed and the user is directed back to Rippling, you will call [POST Mark App Installed](https://developer.rippling.com/documentation/base-api/reference/post-mark-app-installed) to finalize the installation.

**Example request:**

```text
curl -L -X POST 'https://api.rippling.com/platform/api/mark_app_installed' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer REDACTED
```

**Example response:**

```text
{
  "ok": true
}
```

### Refresh tokens

To retrieve a Refresh Token, send a POST request to the same API Token URL with basic auth and your client ID and secret and the following form parameters:

| Refresh Query Parameters | Description |
| --- | --- |
| grant\_type | refresh\_token |
| refresh\_token | Refresh token from the initial grant. |

**Example request:**

```text
curl "https://api.rippling.com/api/o/token/" -X POST -H "Authorization: Basic REDACTED" -F "grant_type=refresh_token" -F "refresh_token=INSERTFREFRESHTOKEN"  
```

-   The `REDACTED` should be replaced with Base64 encoding of the `client_id:client_secret` string in the request header.
    
-   The `INSERTFREFRESHTOKEN` should be replaced with your **existing refresh token**.
    

## Linking the OAuth tokens with the Rippling company

Now that the connection has been made, your server should request the company information. This information can then be matched with your application's internal database so that you can link the tokens with the corresponding Rippling Company.

**Current company**

Retrieve the current company's information with the [GET List Companies](https://developer.rippling.com/documentation/rest-api/reference/list-companies) endpoint. Note, the fields returned will depend on the scopes the customer has authorized your service to access.

**Request**

```text
curl --location --request GET 'https://rest.ripplingapis.com/companies' \
--header 'Authorization: Bearer REDACTED'
```

**Response**

```json
{
    "id": "595f75ffd2a5f80ae22ce88e",
    "ein": "123121111",
    "address": {
        "city": "San Francisco",
        "state": "CA",
        "country": "US",
        "zip": "94110",
        "streetLine1": "3000 Mission Street"
    },
    "workLocations": [
        {
            "id": "5984bca87ee766438fd6faa5",
            "nickname": "SF",
            "address": {
                "city": "Salem",
                "zip": "97317",
                "streetLine1": "4000 Mission Street Southeast",
                "country": "US",
                "state": "OR",
                "steLocationCode": {
                    "cityCode": "0004491020",
                    "psdCode": "",
                    "schoolCode": "",
                    "countyCode": "047",
                    "stateCode": "41",
                    "municipalityCode": "",
                    "transitDistrictCode": "",
                    "locationCode": "41-047-0004491020"
                }
            }
        }
    ],
    "primaryEmail": "aamir+prod@rippling.com",
    "phone": "9892471335",
    "name": "Bob's Bakery"
}
```

## FAQs

#### Do authorization codes expire?

Yes, authorization codes expire after 300 seconds.

#### Can authorization codes from installs be used more than once?

No, authorization codes can only be used a single time.

#### Do I have to retrieve an access token within 300 seconds of receiving the authorization code?

Yes, your integration needs to retrieve an access token within 300 seconds of receiving the authorization code.

#### What do I do if I miss the window to retrieve an access token with my authorization code?

Go back to your installation in Rippling. You can pick up where you left off in the installation flow. Click the **Redirect** button again on the Redirect installation flow screen. This will generate a new authorization code.

#### Do access tokens expire?

Yes, access tokens will expire.

#### How long are access tokens valid for?

Use the `expired_in` output as part of the response from the token endpoint to tell how long the access token is valid for. It is important that your integration uses the seconds populated in the `expired_in` output to understand when an access token will expire.

#### When will my access token expire?

The lifetime of access tokens can be read during the initial retrieval of the access tokens. Third-party applications are responsible for tracking the expiration of their tokens and using refresh tokens to retrieve new access tokens once their access tokens expire.

#### Can access tokens be used multiple times in an hour to fetch information from many Rippling API endpoints?

Yes, they can. Once you have an access token, you can use it to call any of the API endpoints your app is scoped for.

#### Do refresh tokens expire?

Once a refresh token is used to retrieve another access token, that refresh token will be revoked. Refresh tokens are revoked once they are used.

#### The access and refresh tokens have been revoked for a customer app install. How should we resolve this?

To fetch a new token pair, the customer will need to uninstall/reinstall or reauthorize (navigate to `https://app.rippling.com/apps/PLATFORM/{INSERTAPPNAME}/authorize`) the app listing in their Rippling account.

In doing this, the customer will be redirected to the redirect URL configured in your app with a new authorization code. You can then use that authorization code and redeem it for a new access and refresh token pair.

#### Can refresh tokens be used more than once?

Refresh tokens have a 1-hour grace period after their first usage in which applications can reuse them to retrieve a new set of access and refresh tokens. Refresh tokens can only be used once because their usage should result in an additional access token and refresh token. Refresh tokens allows clients to continue to have a valid access token without further interaction with the user.

#### If I have new scopes added to my app, will our app automatically have access to that information for currently-installed customers?

No, current installs will need to reauthorize the app in order to grant the app access to the new scopes. For example, if you have three customers with active app installations, each of these customers will need to reauthorize and consent to the scopes now available in the app.

To reauthorize, admins must be directed to the Authorize installation step of their app's installation flow. The template URL for this step is: [https://app.rippling.com/apps/PLATFORM/{APPNAME}/authorize](https://app.rippling.com/apps/PLATFORM/%7BAPPNAME%7D/authorize). Once their the admins would then proceed through the rest of the installation flow and finish the installation.

Additionally, the customer can also reauthorize by uninstalling the existing app completely and reinstalling the app from scratch. The admin can uninstall the existing app by going to the the _app in Rippling > Settings > Uninstall._

#### Can we configure multiple redirect URLs for our app?

For more information on redirect URLs and common questions surrounding this, please see [Redirect URLs](https://developer.rippling.com/documentation/developer-portal/v2-guides/redirect).

#### How do we know when our app has been uninstalled by a customer?

Rippling will send a `company.deleted` event when a Rippling customer has uninstalled your app. The webhook will look like this:

```json
event_name=company.deleted&id=583fd8803bf207cab80269b9&company_id=583fd8803bf207cab80269b9&company_primary_email=huroncompany%2Bfake%40rippling.com
```

Additionally, any endpoint will return a `403` error code with a response of:

`{ "detail": "The token has been revoked" }`

> **Need Support?**
> If you're a partner seeking answers or encountering difficulties while integrating with Rippling, please contact us at [partner.support@rippling.com](mailto:partner.support@rippling.com). Ensure our responses reach you by preventing emails from this address from being filtered into your spam folder.

Source: https://developer.rippling.com/documentation/developer-portal/v2-guides/installation

> For the complete documentation index, see [llms.txt](https://developer.rippling.com/llms.txt). Public pages have a Markdown version at the same URL with .md added.
