Sample Flow: Authorizing Guest Users and Calling Commerce APIs
Once the external client app is set up and you have the consumer details, including Consumer Key and Consumer Secret, you’re ready to use the Headless Guest Flow. Issue identifiers in the form of unique visitor IDs (UVIDs) for these unknown visitors with the Headless Guest Flow. See Headless Identity APIs: Headless Guest Flow for Public Clients for more information.
Request Authorization Code for the Guest User
Authorization
The first step is to authorize the guest user. The following is an example of an authorization request.
Salesforce validates the UVID and authorizes the guest user. If the UVID was passed as a JWT-based access token, Salesforce checks the validity of the token. The API returns the code response with the authorization and other parameters.
Note: For guest user authentication flows, include the Uvid-Hint and Auth-Request-Type guest headers in the token request. Requests that omit these headers can return an unknown_error response.
1grant_type=authorization_code2code={AUTHORIZATION_CODE}/*Received using the Authorize POST request*/3client_id={CONSUMER_KEY}4client_secret={CONSUMER_SECRET}5redirect_uri={CALLBACK_URL}
Response
Your app processes the access token response and creates a guest session, persisting the UVID value.