Skip to main content

ID Token API

Info

App Bridge isn't versioned with Polaris. App Bridge APIs and web components are identical in every App Home reference version.

The ID Token API retrieves an OpenID Connect ID Token from Shopify as a JWT string. Your backend can verify this token to confirm that a request came from an authenticated Shopify user.

In most cases, you don't need to call this method directly. App Bridge's fetch interceptor automatically includes the ID token in the Authorization header for requests to your app's domain. Use shopify.idToken() directly when you need the token for something other than a standard fetch request, such as a WebSocket connection to your backend.

For more information, see the ID token documentation.

  • Backend authentication: Verify requests to your backend are from a Shopify-authenticated user.
  • Session validation: Validate user sessions without requiring traditional cookie-based authentication.
  • Secure communication: Exchange ID tokens for secure communication between your app frontend and backend.

Send ID tokens to your own backend only. Verifying the signature requires your client secret, so a third-party service can't check it without a credential that also lets it mint tokens your app would accept.

The idToken API is available on the shopify global. It returns a Promise that resolves to a JWT string.

Promise<string>
Examples

js

const token = await shopify.idToken();
// => 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...'

Was this page helpful?