Session-aware access tokens

Learn how to create session-aware access tokens.

The session-aware access token links a Global Commerce shopper session to an access token as well as provide the ability to continue a shopper workflow with a previously established shopper session.

To create a session-aware access token, use the sessionToken query parameter or dr_session_token form parameter, depending on the workflow.

circle-exclamation

You can create a session-aware token by either sending a browser call or a request to the Token endpoint in either the Shopper APIarrow-up-right or the OAuth APIarrow-up-right.

circle-info

If you provide a session token when generating an access token, the system creates a new shopper session.

You can choose one of the following options to create a session-aware access token:

Creating an anonymous shopper token for a site with an API key

Establish an anonymous shopper (limited access) token in a single call by passing in your API key to the sessionToken site action.

circle-exclamation
Example
function sessionToken() {
       $.ajax({
          url: "https://store.digitalriver.com/store/[siteID]/SessionToken?apiKey=[apiKey]]&format=json",
           type: 'GET',
           async: false,
           contentType: "application/json",
           dataType: "jsonp",
            error: function (data) {
            },
            success: function (data) {
             }
        });
}

Creating an anonymous shopper token for a site via OAuth 2.0

This example requires two calls; one to get the session token, and another to create the access token.

Step 1: Get a dr_session_token from the sessionToken site action with no API key

circle-exclamation

Step 2: POST the dr_session_token to the oauth20 resource, to get an anonymous shopper token.

circle-info

The time-to-live (TTL) value for expires_in respects the user session site settings in Global Commerce. In this example, the token for the site expires in 86397 seconds (24 hours).

Last updated