## Entitlements object

An Entitlements Object is a JSON representation of a single entitlement for a publication, to be associated with a subscription-linked reader account.

### Fields

- **product_id**: An identifier formed by merging the publication ID and the name or level of entitlement.

> [!NOTE]
> **Note:** Publication ID is a domain name (e.g.**example.com** ) for publishers migrating from the legacy Subscribe with Google. For newly onboarding publishers, it is an auto-generated ID, which can be found in the `publication` query parameter in your Publisher Center URL. For example, if the URL ends with `?publication=CAow-7jBCw`, then **CAow-7jBCw** is your Publication ID.

- **subscription_token**: A publisher-provided string representing their understanding of a subscription. Google stores this, but does not use it for anything.
- **detail**: A user-facing description of the entitlement. This is surfaced in the reader's self-service My Accounts page for better identifying their entitlements.
- **expire_time** : A timestamp in [RFC 3339 format](https://www.ietf.org/rfc/rfc3339.txt). The maximum `expire_time` is 398 days from `now()`. If you need to support a longer entitlement period, you must update the `expire_time` to extend it before it reaches the `expire_time`.

### Entitlements object example

    const entitlement = {
      "product_id": "dailybugle.com:basic",
      "subscription_token": "dnabhdufbwinkjanvejskenfw",
      "detail": "This is our basic plan",
      "expire_time": "2022-08-19T04:53:40+00:00"
    }

## Background on GCP OAuth service accounts

- Creating [an OAuth service account](https://developers.google.com/identity/protocols/oauth2/service-account)
- [Using JWT for signed HTTP REST requests](https://developers.google.com/identity/protocols/oauth2/service-account#httprest)
- [Officially supported client libraries](https://developers.google.com/identity/protocols/oauth2/web-server#libraries)
- Example of using a service account with a client library via the [node.js example](https://github.com/googleapis/google-api-nodejs-client#service-account-credentials).