Skip to content

Commit 62bdfdb

Browse files
authored
Merge pull request #2960 from Shopify/06-06-added_docs_on_session_tokens_and_app_permissions
Added docs on session tokens and app permissions
2 parents 60fb008 + 2944b71 commit 62bdfdb

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

packages/ui-extensions/docs/surfaces/point-of-sale/staticPages/pages/pos-overview.doc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const data: LandingTemplateSchema = {
8383
},
8484
],
8585
sectionContent:
86-
"POS UI extensions can also make authenticated calls to your app's backend. When you use `fetch()` to make a request to your app's configured auth domain or any of its subdomains, an `Authorization` header is automatically added with a Shopify [OpenID Connect ID Token (formerly known as a Session Token)](https://shopify.dev/docs/api/app-bridge-library/reference/id-token). There's no need to manually manage ID tokens.\n\nRelative URLs passed to `fetch()` are resolved against your app's `app_url`. This means if your app's backend is on the same domain as your `app_url`, you can make requests to it using `fetch('/path')`.\n\nIf you need to make requests to a different domain, you can use the [`session.getSessionToken()` method](/docs/api/pos-ui-extensions/apis/session-api#sessionapi-propertydetail-getsessiontoken) to retrieve the ID token and manually add it to your request headers.",
86+
"POS UI extensions can also make authenticated calls to your app's backend. When you use `fetch()` to make a request to your app's configured auth domain or any of its subdomains, an `Authorization` header is automatically added with a Shopify [OpenID Connect ID Token (formerly known as a Session Token)](/docs/api/app-bridge-library/reference/id-token). There's no need to manually manage ID tokens.\n\nRelative URLs passed to `fetch()` are resolved against your app's `app_url`. This means if your app's backend is on the same domain as your `app_url`, you can make requests to it using `fetch('/path')`.\n\nIf you need to make requests to a different domain, you can use the [`session.getSessionToken()` method](/docs/api/pos-ui-extensions/apis/session-api#sessionapi-propertydetail-getsessiontoken) to retrieve the ID token and manually add it to your request headers.\n\n**Important**: ID tokens are only returned for authenticated users who are permitted to use your app. When the authenticated user (the user that logged into Shopify POS with their email address) doesn't have the correct app permission enabled for your app, the token will be null. This is irrelevant of which POS Staff member is pinned in, as those are not authenticated users. For more information on configuring app permissions, see the [Shopify app permissions documentation](https://help.shopify.com/en/manual/your-account/users/roles/permissions/store-permissions#apps-and-channels-permissions).",
8787
anchorLink: 'app-authentication',
8888
codeblock: {
8989
title: "Make requests to your app's backend",

packages/ui-extensions/docs/surfaces/point-of-sale/staticPages/pages/troubleshooting.doc.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,24 @@ This error is most likely from missing a dependency in package.json in the app r
9999
100100
This issue commonly happens when \`Yarn\` is used for dependency management. The package's version was updated but \`npm\` conflicts with \`Yarn\`. In the root of your application run \`npm install\` to get it up to date as well. Restart your IDE if necessary.`,
101101
},
102+
{
103+
type: 'Generic',
104+
anchorLink: 'session-token-null',
105+
title: 'Session tokens are being returned as null',
106+
sectionContent: `
107+
### Resolution
108+
109+
The \`getSessionToken()\` function returns \`null\` when the authenticated user (the user that logged into Shopify POS with their email address) doesn't have the correct app permissions enabled for your app. Session tokens are only returned for authenticated users who have enabled the correct app permission for the app making the request. This is irrelevant of POS Staff members, as those are not authenticated users.
110+
111+
To resolve this issue:
112+
113+
1. **Check app permissions**: Verify that the authenticated user has the correct app permission enabled for your app. This can be seen in the Shopify Admin by navigating to Settings > Users > Select a user > Scroll down to view the permissions summary.
114+
115+
2. **Enable app permissions**: If the user does not have permissions to use your app, it can be added to one of the roles that is assigned to that user. This can be done in the Shopify Admin by navigating to Settings > Users > Roles > Select a role. You can then scroll down to the apps section and select the app for which you want to grant the user permissions.
116+
117+
For more information on configuring and managing app permissions, see the [Shopify app permissions documentation](https://help.shopify.com/en/manual/your-account/users/roles/permissions/store-permissions#apps-and-channels-permissions).
118+
`,
119+
},
102120
],
103121
};
104122

packages/ui-extensions/src/surfaces/point-of-sale/render/api/session-api/session-api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export interface SessionApiContent {
77
currentSession: Session;
88
/**
99
* Get a fresh session token for communication with your app's backend service.
10+
* When the authenticated user (the user that logged into Shopify POS with their email address) doesn't have the correct app permissions enabled for your app, null will be returned. This is irrelevant of which POS Staff member is pinned in, as those are not authenticated users.
11+
* For more information, see our [app permissions documentation](https://help.shopify.com/en/manual/your-account/users/roles/permissions/store-permissions#apps-and-channels-permissions).
1012
* Calls to Shopify APIs must be made by your app’s backend service.
1113
*/
1214
getSessionToken: () => Promise<string | undefined>;

0 commit comments

Comments
 (0)