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

Support App Bridge 2.0 in shopify_app #1241

Merged
merged 2 commits into from
Apr 19, 2021
Merged

Conversation

rezaansyed
Copy link
Contributor

@rezaansyed rezaansyed commented Apr 1, 2021

What this PR does

⚠️ This is a breaking change

Support App Bridge 2.0 in shopify_app.

Reviewer's guide to testing

  • Import local version of this branch to new app
  • Ensure that app runs as expected in Admin

Things to focus on

Ensure migration strategy is followed as per the guide.

Checklist

Before submitting the PR, please consider if any of the following are needed:

  • Update CHANGELOG.md if the changes would impact users
  • Update README.md, if appropriate.
  • Update any relevant pages in /docs, if necessary
  • For security fixes, the Disclosure Policy must be followed.

Copy link

@hannachen hannachen left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

Copy link
Contributor

@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.

Haven't 🎩 ed it, but the code looks good.

Copy link
Contributor

@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.

I've tried this out now, and I got the following error:

message: "APP::ERROR::INVALID_CONFIG: host must be provided"
name: "AppBridgeError"
type: "APP::ERROR::INVALID_CONFIG"

It seems that coming back from OAuth, we're lacking the host parameter and thus we can't load App Bridge properly.

@rezaansyed
Copy link
Contributor Author

I've tried this out now, and I got the following error:

message: "APP::ERROR::INVALID_CONFIG: host must be provided"
name: "AppBridgeError"
type: "APP::ERROR::INVALID_CONFIG"

It seems that coming back from OAuth, we're lacking the host parameter and thus we can't load App Bridge properly.

Noticing that on my end too. It has to do with the HomeController not having the host param passed in and can't initialize App Bridge at the top level. Is there any way for us to know of the host during OAuth @hannachen?

@NabeelAhsen
Copy link
Contributor

If the host parameter is part of the callback URL sent by Shopify to the app, step 3 of this doc might be outdated: https://shopify.dev/tutorials/authenticate-with-oauth#step-3-confirm-installation

Is this where the host parameter is initially supposed to come from?

@rezaansyed
Copy link
Contributor Author

If the host parameter is part of the callback URL sent by Shopify to the app, step 3 of this doc might be outdated: https://shopify.dev/tutorials/authenticate-with-oauth#step-3-confirm-installation

Is this where the host parameter is initially supposed to come from?

It's not part of the callback controller. The failure happens when hitting the home controller at the top level right after the callback controller though.

@paulomarg
Copy link
Contributor

paulomarg commented Apr 5, 2021

Should we be including the host in the redirect URL when we begin OAuth? That way, we'd be able to reference it when coming back.

@NabeelAhsen NabeelAhsen self-assigned this Apr 14, 2021
@NabeelAhsen NabeelAhsen force-pushed the support-app-bridge-2-0 branch from fd775a1 to a708424 Compare April 14, 2021 15:45
@NabeelAhsen NabeelAhsen requested a review from paulomarg April 14, 2021 15:47
Comment on lines +227 to +228
return_address_with_params(shop: current_shopify_domain, host: host)
rescue ShopifyDomainNotFound, ShopifyHostNotFound
Copy link
Contributor

Choose a reason for hiding this comment

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

This is needed because of the following:

def respond_successfully
if jwt_request?
head(:ok)
else
redirect_to(return_address)
end
end

Copy link
Contributor

Choose a reason for hiding this comment

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

Things I'm unsure about here:

  • Right now, there are two known places that use return_address in this code base. Is raising when host isn't found the the correct move here?
  • What other tests are affected by this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Considering we currently throw a similar exception for the domain, it makes sense to me to continue to throw here.

@NabeelAhsen
Copy link
Contributor

NabeelAhsen commented Apr 14, 2021

I've tried this out now, and I got the following error:

message: "APP::ERROR::INVALID_CONFIG: host must be provided"
name: "AppBridgeError"
type: "APP::ERROR::INVALID_CONFIG"
It seems that coming back from OAuth, we're lacking the host parameter and thus we can't load App Bridge properly.

All apps should now be receiving the host param on OAuth callback. I verified this by creating a new app using this branch and checking the OAuth callback redirects.

Should we be including the host in the redirect URL when we begin OAuth? That way, we'd be able to reference it when coming back.

This host param comes from Shopify's generated URLs, so we'd only be aware of them on OAuth return

Copy link
Contributor

@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.

🎩 ed again, OAuth worked correctly for me now.

Comment on lines +227 to +228
return_address_with_params(shop: current_shopify_domain, host: host)
rescue ShopifyDomainNotFound, ShopifyHostNotFound
Copy link
Contributor

Choose a reason for hiding this comment

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

Considering we currently throw a similar exception for the domain, it makes sense to me to continue to throw here.

@NabeelAhsen NabeelAhsen merged commit 25f1db8 into master Apr 19, 2021
@NabeelAhsen NabeelAhsen deleted the support-app-bridge-2-0 branch April 19, 2021 18:07
@NabeelAhsen NabeelAhsen mentioned this pull request Apr 19, 2021
4 tasks
@rezaansyed rezaansyed mentioned this pull request May 3, 2021
4 tasks
@shopify-shipit shopify-shipit bot temporarily deployed to rubygems May 3, 2021 21:35 Inactive
@asecondwill
Copy link

This does not work when trying to update a JWT Turbo Example app. Please can you test with that and provide instructions @NabeelAhsen

@asecondwill
Copy link

no host param comes back. this is URGENT because the review team insist on App Bridge 2. PLEASE HELP.

@asecondwill
Copy link

Probably worth noting, host is not passed back in the params @paulomarg

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.

5 participants