Skip to navigation

Get Storefront authToken Within Stencil

Uses a JSON web token (JWT) from a particular customer or Company user who is currently logged in to the storefront to create a storefront authToken for future requests.

To learn more about how you can retrieve a JWT to create a storefront authToken. See Authentication for hosted storefronts.

Equivalent Storefront GraphQL API Mutation: authorization.

Example GraphQL API Body

copy
mutation {
authorization(
authData: {
bcToken: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6ImtpZG8yNzZAc25hcG1haWwuY2MiLCJzdG9yZV9oYXNoIjoiMWk2enB4cGUzZyIsImRiIjoiZGVmYXVsdCIsIm5hbWUiOiJ0ZXN0OSIsImNoYW5uZWxfaWRzIjpbMV0sInRva2VuX3R5cGUiOjMsIm5iZiI6MTAwMCwiZXhwIjoyMDAxfQ.EiR__LVAlBVNYtFCZPWJYoPv6UfGiXtULxhK-BCQZjY",
channelId: 1
}
) {
result {
token
}
}
}

Example GraphQL API Response

copy
{
"data": {
"authorization": {
"result": {
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6ImtpZG8yNzZAc25hcG1haWwuY2MiLCJzdG9yZV9oYXNoIjoiMWk2enB4cGUzZyIsImRiIjoiZGVmYXVsdCIsIm5hbWUiOiJ0ZXN0OSIsImNoYW5uZWxfaWRzIjpbMV0sInRva2VuX3R5cGUiOjMsIm5iZiI6MTAwMCwiZXhwIjoyMDAxfQ.EiR__LVAlBVNYtFCZPWJYoPv6UfGiXtULxhK-BCQZjY"
}
}
}
}

Request

This endpoint expects an object.
bcTokenstringRequired

The JSON Web Token (JWT) obtained from a signed-in Company user. See Current Customer API to learn how to request a JWT.

storeHashstringOptional
The unique store hash for the BigCommerce store.
channelIddoubleOptionalDefaults to 1

The storefront channel ID associated with the storefront login session. Use 1 for your store’s default storefront channel.

customerIdintegerOptional
The BigCommerce customer ID associated with a Company user.

Response

OK
codedoubleOptionalDefaults to 200
dataobjectOptional
messagestringOptional