-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
4. Add react app bridge and retrieve and log session tokens #13
Conversation
MuhammadFarag
commented
May 6, 2021
- Enable React
- Add Appbridge
- Retrieve and log session token
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff!
README.md
Outdated
- SCOPES | ||
- HOST_NAME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've had comments before that we should prefix all of our env vars, so this would look something like:
- SCOPES | |
- HOST_NAME | |
- SHOPIFY_APP_SCOPES | |
- SHOPIFY_APP_HOST |
Is that doable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
package.json
Outdated
"@shopify/app-bridge": "^1.30.0", | ||
"@shopify/app-bridge-utils": "^1.30.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mentioned this in another PR, but we should support App Bridge 2.0 from the get-go here - that's surely going to trip partners up later if we don't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
resources/js/react/App.jsx
Outdated
import createApp from "@shopify/app-bridge"; | ||
import { getSessionToken } from "@shopify/app-bridge-utils" | ||
|
||
function App({shop, apiKey}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest we copy the _app.js file from https://github.com/Shopify/shopify-app-node/blob/master/pages/_app.js which has a lot of things we'll end up needing to handle here (like authenticatedFetch
and the custom X-Shopify-API-Request-Failure-Reauthorize-Url
which we'll also need to add here (as part of the middleware to check for a valid session).
But we should definitely add a ClientRouter
to it since that question has come up repeatedly in that repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
authenticated fetch is added in the following PR #14. I am just trying to create a smaller easier to review PRs. I added a todo for X-Shopify-API-Request-Failure-Reauthorize-Url
on that PR as well.
Updated this note https://github.com/orgs/Shopify/projects/1185#card-59723312, so we don't forget about ClientRouter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds great, I think the redirect header won't come into play until we add the middleware for checking for a current session though! We can definitely move ahead with what we have here!
063de38
to
4e9e29d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, though we may want to pare down the tests here too.
tests/Feature/CallbackTest.php
Outdated
Context::$SESSION_STORAGE->storeSession($this->session); | ||
|
||
|
||
$matcher = new HttpRequestMatcher( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably trim this test down as we did the other one!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure 👍
bc5776e
to
62adb6b
Compare