AI-generated Key Takeaways
-
An Entitlements Object is a JSON object representing a publication's entitlement linked to a reader's subscription.
-
It includes fields for product ID, publisher-provided subscription token, user-facing description, and an expiration timestamp.
-
Entitlements have a maximum duration of 398 days and require updating the
expire_time
field for extensions. -
Google provides resources and examples for creating OAuth service accounts and using JWT for secure communication.
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.
- 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. The maximum
expire_time
is 398 days fromnow()
. If you need to support a longer entitlement period, you must update theexpire_time
to extend it before it reaches theexpire_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
- Using JWT for signed HTTP REST requests
- Officially supported client libraries
- Example of using a service account with a client library via the node.js example.