Get Storefront authToken Within Stencil
Uses a [JSON web token](/developer/docs/storefront/guides/customer-authentication/current-customer) (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](/developer/docs/b2b-edition/getting-started/authentication).
Equivalent Storefront GraphQL API Mutation: `authorization`.
### Example GraphQL API Body
``` graphQL copy
mutation {
authorization(
authData: {
bcToken: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6ImtpZG8yNzZAc25hcG1haWwuY2MiLCJzdG9yZV9oYXNoIjoiMWk2enB4cGUzZyIsImRiIjoiZGVmYXVsdCIsIm5hbWUiOiJ0ZXN0OSIsImNoYW5uZWxfaWRzIjpbMV0sInRva2VuX3R5cGUiOjMsIm5iZiI6MTAwMCwiZXhwIjoyMDAxfQ.EiR__LVAlBVNYtFCZPWJYoPv6UfGiXtULxhK-BCQZjY",
channelId: 1
}
) {
result {
token
}
}
}
```
### Example GraphQL API Response
``` json copy
{
"data": {
"authorization": {
"result": {
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6ImtpZG8yNzZAc25hcG1haWwuY2MiLCJzdG9yZV9oYXNoIjoiMWk2enB4cGUzZyIsImRiIjoiZGVmYXVsdCIsIm5hbWUiOiJ0ZXN0OSIsImNoYW5uZWxfaWRzIjpbMV0sInRva2VuX3R5cGUiOjMsIm5iZiI6MTAwMCwiZXhwIjoyMDAxfQ.EiR__LVAlBVNYtFCZPWJYoPv6UfGiXtULxhK-BCQZjY"
}
}
}
}
```
Request
This endpoint expects an object.
bcToken
The JSON Web Token (JWT) obtained from a signed-in Company user. See Current Customer API to learn how to request a JWT.
storeHash
The unique store hash for the BigCommerce store.
channelId
The storefront channel ID associated with the storefront login session. Use 1 for your store’s default storefront channel.
customerId
The BigCommerce customer ID associated with a Company user.
Response
OK
code
data
message