Both are created in Settings → OAuth and belong to an
environment. Send the returned
access_token as Authorization: Bearer <token> on every Storefront request.
OAuth clients (servers)
1
Create the client
Go to Settings → OAuth → Clients → New client. Pick an environment, a
name and the scopes the integration needs (for example
customers:read
and events:write).2
Copy the credentials
Copy the
client_id (mv_…) and the client_secret (mvs_…). The secret
is shown only once; Masivo only stores its hash. Use Rotate secret
if it leaks.3
Request a token
Use the client credentials grant:
scope to get every scope of the client. Asking for a scope the client
doesn’t have fails with invalid_scope.
Scopes
Scopes follow<resource>:read|write. read covers GET and HEAD; write
covers every other method. The resource comes from the first path segment
after /api/storefront/v1/. A path missing from this table is denied to every
OAuth token.
For example,
POST /behavior/events needs events:write and
GET /customers/{id} needs customers:read. A request without the needed
scope gets 403 with Insufficient scope. Required: <scope>.
OAuth apps (front ends)
An OAuth app tells Masivo to trust the ID tokens of your identity provider. After the user signs in, your front end trades the provider’s ID token for a Masivo token that only reaches that customer’s own data (RFC 8693 token exchange):App fields
How the exchange works
- Masivo reads
issandaudand finds the active OAuth apps with that issuer and audience. - With several matches it uses the one whose alias equals the
audienceparameter. - It verifies the signature with the provider keys, plus issuer, audience and expiry.
- It reads the Customer ID claim and signs a token with
scope: CUSTOMER,customer_id,oauth_app_idandenv.
What a customer token can do
On/customers/{id}, only when {id} is its own customer_id:
Outside
/customers it reaches the same paths as a CLIENT API key:
behavior/events, behavior/events/bulk, inapp/capabilities,
news-feed/capabilities, deeplinks/resolve, reviews and review-forms/*.
- The profile
PATCHonly acceptsname,dob,gender,document_type,document_number,countryandphone. - Every event must carry the token’s
customer_id, in bulk too. PURCHASEand other trusted writes still need an OAuth client.
Customer ID claim
Masivo does not look customers up by email or any other field. It reads one claim of the ID token and uses its value, as is, as the Masivo customer ID. The Customer ID claim field holds the name of that claim, never a value.
Why
sub is the default. OpenID Connect defines sub as the stable,
unique identifier of the user at the provider. Every provider sends it and it
never changes when the user edits their profile.
Don’t use email. Masivo customer IDs only allow letters, digits, _ and
- (^[a-zA-Z0-9_-]+$), so an email never matches a customer. Emails also
change, and some providers accept unverified ones.
What this means for your customers. Each customer must exist in Masivo
with the provider’s user ID as its ID. Create it from your backend (OAuth
client with customers:write) when the user registers:
cust_123), add
a custom claim with that ID in your provider and set Customer ID claim to
its name, for example masivo_customer_id.
Sharing a provider between accounts
A brand with one account per country often has a single Firebase project for all its apps. Each account can trust that provider with its own OAuth app:- Only a user who belongs to every account that already trusts the issuer and audience can add it to another account. Otherwise the dashboard answers This issuer and audience belong to another account.
- Give each OAuth app a different Alias (for example
brand-ecandbrand-pe). - Each front end sends its alias as
audiencein the exchange. Without it the exchange fails withinvalid_request; Masivo never guesses the account.
Errors
Both endpoints answer standard OAuth errors ({ "error", "error_description" }):
Tokens are valid until they expire (1 hour). Disabling a client or app, or
rotating a secret, stops new tokens but doesn’t revoke tokens already issued.
The customer token exists only after the user signs in. Calls made before
that (resolving deferred deep links, registering an install on first launch)
still need a CLIENT API key.