-
Notifications
You must be signed in to change notification settings - Fork 77
Open
Description
Issue summary
The comment in useAuthenticatedFetch seems to be inaccurate:
shopify-frontend-template-react/hooks/useAuthenticatedFetch.js
Lines 5 to 17 in 1e92031
/** | |
* A hook that returns an auth-aware fetch function. | |
* @desc The returned fetch function that matches the browser's fetch API | |
* See: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API | |
* It will provide the following functionality: | |
* | |
* 1. Add a `X-Shopify-Access-Token` header to the request. | |
* 2. Check response for `X-Shopify-API-Request-Failure-Reauthorize` header. | |
* 3. Redirect the user to the reauthorization URL if the header is present. | |
* | |
* @returns {Function} fetch function | |
*/ | |
export function useAuthenticatedFetch() { |
This header is not added, and indeed it should not be - the Access Token should be added on the backend, not from the frontend, if I'm reading Shopify docs correctly. This OAuth tutorial explicitly says that this header is added on the backend, and the App Bridge tutorial says that authenticatedFetch
is supposed to add the Session Token under the Authorization
header.
Expected behavior
The comment should be rewritten to explain what the function actually does:
- It adds an
Authorization
header to the request, with the valueBearer <Session Token Here>
Actual behavior
Inaccurate comment
Metadata
Metadata
Assignees
Labels
No labels