Tokens

Imagine you've built an online clothing store. You want the online store site your customers see to load and show the products you added in Content Studio. But the site is a program, not a person, so it can't log in the way a person does. A token is the secret key you issue so that a site or program can access your content in place of a person.

Whoever holds a token can work with content within a set scope, without logging in. That's why you treat a token like a password: if it leaks, whoever gets hold of it can use everything the token is allowed to do.

WEEGLOO has three tokens, each for a different use. This page first compares when to use each one, then walks through how the online store site reads published products with a Delivery Access Token.

Three tokens for different uses

The three tokens differ in who uses them, how far they reach, and what they can do.

Personal Access TokenSpace Access TokenDelivery Access Token
Who uses itA program that works for youA server that adds and edits content in one Space, or a site that takes posts from customers who aren't logged inA public site that shows your published content
Clothing store exampleA program that uploads new arrivals every nightA server that adds products automaticallyThe online store site your customers see
Where it worksEvery Organization and Space your account belongs toThe one Space it was issued inThe one Space it was issued in
What it can doRead and write, within your account's permissionsRead and write, within the bound role's permissionsOnly read Published content, within the bound role's permissions

Use a Personal Access Token when you hand a program work that moves across several Spaces or even handles Space settings. Use a Space Access Token when the work has to add and edit content inside one Space, and a Delivery Access Token when a public site only reads and shows published content.

A Personal Access Token is a powerful token that follows your account's permissions, so keep it only on the server where the program runs. If you put it in a site that's delivered to customers, anyone who opens that site can dig out the token value. A Space Access Token can also sit on the customer side, for example in a site that takes inquiries from customers who aren't logged in. In that case, bind a role so narrow that you could live with the token leaking. Where each token can and can't be kept is covered in Where to keep each token's secret value.

For the steps to issue a Personal Access Token or a Space Access Token, see Issue a Personal Access Token and Issue a Space Access Token. The rules for all three tokens, such as what you can change after issuing, how long they stay valid, and what a token can't do, are in Token rules.

Bind a narrow role to limit what a token can do

When you issue a Space Access Token or a Delivery Access Token, you bind one SpaceRole (role) to it. A role is a set of permissions that defines what can be worked on and which actions are allowed. A token can do only what its bound role allows.

So bind a narrow role that allows only the actions the token's job needs. The Delivery Access Token "Online Store Site Delivery", used by the online store site, gets the role "Product Read-Only", which allows only Read on product Content. This token can read only products, so even if its value leaks, it can't be used to read any other content. The Space Access Token "New Arrivals Auto-register Server", used by the server that adds products automatically, gets the role "Product Editor". That role allows Read, Create, and Edit on product Content and Read on the product Content Type, and leaves out Delete and Publish.

Don't bind the Administrator role, which can do everything, to a token. The broader the role you bind, the more someone else can do with the token if its value leaks.

You don't bind a role to a Personal Access Token, because it follows the permissions of the account that issued it.

Which roles you can bind, and what else the role must allow when the site also shows the photos linked to products, are covered in Roles you can bind. For what happens to a token when you edit its role, and what to watch for when you change the bound role after issuing, see The bound role decides what a token can do.

Allowed referrers set which sites can use a token

When you issue a Space Access Token or a Delivery Access Token, you use Allowed referrers to set which sites can use the token. If you leave it at its starting value, No restriction, the token works from any site. If you enter the online store site's address in Allowed referrers for "Online Store Site Delivery", no other site can use this token (Allowed referrers decide which sites can use a token).

Why you leave a token used on a server at No restriction is explained in Allowed referrers decide which sites can use a token. For how to write the addresses, see Rules for entering addresses in Allowed referrers.

Getting the online store site to read published products

It takes three steps for the online store site to read products. You do the first two in Content Studio, only once. After that, the site reads published products with the secret value you put in it.

Preparing the role to bind

When you issue a token, you have to select one role to bind, so create that role in your clothing store's Space first. If the online store site only reads products, bind the role "Product Read-Only", which allows only Read on product Content. You create roles under Roles & Permissions in the left menu, and the on-screen steps are in Create a role.

Issuing the token in Content Studio

Issue a new token from the Delivery Access Token screen in your clothing store Space's settings. Name it Online Store Site Delivery, and select "Product Read-Only" under SpaceRole. To make the token usable only from the online store site, enter the site's address in Allowed referrers (Allowed referrers set which sites can use a token). When issuing finishes, the token's detail screen opens, and you copy the token's secret value there. Issuing is done with an account that has the Manage Delivery Access Tokens permission. For the on-screen steps, see Issue a Delivery Access Token.

Putting the secret value in the online store site

Once you put the copied secret value in the online store site, the site reads Published products within what "Product Read-Only" allows. Products in Draft can't be read, so publish the products you want the site to show. Anyone who opens the site can see the secret value in it, so anything this token can read is effectively public (Where to keep each token's secret value). If the value seems to have leaked, see Replace a token for what to do.

What to do next

  • Issue a Delivery Access Token: Takes you screen by screen through issuing "Online Store Site Delivery". The same Manual page also covers the settings and rules of all three tokens, their limits and required permissions, and how to edit, replace, and delete a token.
  • Status and publishing: A Delivery Access Token can read only Published content. This page covers how to publish content.
  • API reference: Covers the technical specifications, such as request formats, that you need to issue a token from a program or include a token value in a request.