Skip to content
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

Merged
merged 7 commits into from
May 11, 2021

Conversation

MuhammadFarag
Copy link
Contributor

  • Enable React
  • Add Appbridge
  • Retrieve and log session token

@MuhammadFarag MuhammadFarag requested a review from a team as a code owner May 6, 2021 06:55
Copy link
Collaborator

@paulomarg paulomarg left a 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
Comment on lines 10 to 11
- SCOPES
- HOST_NAME
Copy link
Collaborator

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:

Suggested change
- SCOPES
- HOST_NAME
- SHOPIFY_APP_SCOPES
- SHOPIFY_APP_HOST

Is that doable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

package.json Outdated
Comment on lines 20 to 21
"@shopify/app-bridge": "^1.30.0",
"@shopify/app-bridge-utils": "^1.30.0",
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

import createApp from "@shopify/app-bridge";
import { getSessionToken } from "@shopify/app-bridge-utils"

function App({shop, apiKey}) {
Copy link
Collaborator

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.

Copy link
Contributor Author

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

Copy link
Collaborator

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!

Base automatically changed from unprotected-root-route to main May 11, 2021 18:43
Copy link
Collaborator

@paulomarg paulomarg left a 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.

Context::$SESSION_STORAGE->storeSession($this->session);


$matcher = new HttpRequestMatcher(
Copy link
Collaborator

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!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants