# Session Bridge Authorization

If you have an existing B2C Commerce session from a Storefront Reference Architecture or Site Genesis storefront and you want to get an access token for it, use the [getSessionBridgeAccessToken](https://developer.salesforce.com/docs/commerce/commerce-api/references/auth?meta=getSessionBridgeAccessToken) endpoint.

This can be helpful when building out hybrid storefronts where different technologies are used to power a single shopping experience.

## Prerequisites

- You have configured a SLAS client with the `sfcc.session_bridge` scope.
- For a guest shopper, you have the `dwsgst` value.
- For a registered shopper, you have the `dwsid` value and `login_id`.

The process for getting tokens for sessions is different for guest and registered users. The following call examples use a SLAS private client.

## Session Bridge Guest Shoppers

To bridge a guest session you need a signed guest token from the Script API method [`Session.generateGuestSessionSignature()`](https://salesforcecommercecloud.github.io/b2c-dev-doc/docs/current/scriptapi/html/api/class_dw_system_Session.html#dw_system_Session_generateGuestSessionSignature_DetailAnchor). You must set `login_id` to “guest”:

```sh
curl "https://$CODE.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/$ORG/oauth2/session-bridge/token" \
  --user "$CLIENT:$SECRET" \
  --data 'grant_type=client_credentials' \
  --data 'hint=sb-guest' \
  --data 'login_id=guest' \
  --data "channel_id=$SITE" \
  --data "dwsgst=$DWSGST"
```

## Session Bridge Registered Shoppers

To bridge a registered shopper session you need a signed, registered token (DWSRST) from the Script API method [`Session.generateRegisteredSessionSignature()`](https://salesforcecommercecloud.github.io/b2c-dev-doc/docs/upcoming/scriptapi/html/api/class_dw_system_Session.html#dw_system_Session_generateRegisteredSessionSignature_DetailAnchor). You must set `login_id` to the login ID of the registered shopper.

:::note
- The use of DWSID is still supported, but for performance reasons, use the DWSRST instead of passing in the DWSID.
- In the future, DWSID for registered shopper session bridging will be deprecated.
:::

```sh
curl "https://$CODE.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/$ORG/oauth2/session-bridge/token" \
    --user "$CLIENT:$SECRET" \
    --data 'grant_type=client_credentials' \
    --data 'hint=sb-user' \
    --data "login_id=$SHOPPER" \
    --data "channel_id=$SITE" \
    --data "dwsrst=$DWSRST"
```

The following code sample shows the legacy `dwsid` token. Use `dwsrst` as shown in the previous example.

```sh
curl "https://$CODE.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/$ORG/oauth2/session-bridge/token" \
    --user "$CLIENT:$SECRET" \
    --data 'grant_type=client_credentials' \
    --data 'hint=sb-user' \
    --data "login_id=$SHOPPER" \
    --data "channel_id=$SITE" \
    --data "dwsid=$DWSID"
```
