Shopify_app: I keep getting a InvalidAuthenticityToken error. Could it be because of Rails 5.2.0?

Created on 6 Mar 2018  路  6Comments  路  Source: Shopify/shopify_app

Rails 5.2.0
Ruby: 2.4.1
Browser: Chrome
Operating System: Mac
Hosting Provider: DigitalOcean

I'm trying to create a test Shopify app.

But I keep running into the following error in my logs:

  1. I followed the "Build a Rails App With the Shopify Gem in Five Minutes | Shopify Partners" guide
  2. Uploaded my code to GitHub then Hatchbox and using DigitalOcean
  3. When I go to my given URL I get an error page. So when I look at the rails logs on Hatchbox the four lines which say 'failed':

F, [2018-03-05T23:34:56.533678 #23942] FATAL -- : [a7f46489-9098-48de-a2c3-16325b81744d] F, [2018-03-05T23:34:56.533738 #23942] FATAL -- : [a7f46489-9098-48de-a2c3-16325b81744d] ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken): F, [2018-03-05T23:34:56.533795 #23942] FATAL -- : [a7f46489-9098-48de-a2c3-16325b81744d] F, [2018-03-05T23:34:56.533877 #23942] FATAL -- : [a7f46489-9098-48de-a2c3-16325b81744d] actionpack (5.2.0.rc1) lib/action_controller/metal/request_forgery_protection.rb:211:inhandle_unverified_request'`

I'm not sure what is wrong. Could this be because I'm using Rails 5.2.0?

If you need more information feel free to ask. My repo is private and has my secret API key, thus why I haven't shared it on this issue yet.

Most helpful comment

I'd suggest you try with rails 5.1. It could be due to rails 5.2 easily.

I guess you know this, but I had it at hand:

rails _5.1.5_ new app_testing --database=postgresql
cd app_testing
echo 'gem "shopify_app"' >> Gemfile
bundle install
rails generate shopify_app --api_key <your_api_key> --secret <your_app_secret>

All 6 comments

I'd suggest you try with rails 5.1. It could be due to rails 5.2 easily.

I guess you know this, but I had it at hand:

rails _5.1.5_ new app_testing --database=postgresql
cd app_testing
echo 'gem "shopify_app"' >> Gemfile
bundle install
rails generate shopify_app --api_key <your_api_key> --secret <your_app_secret>

Yes, that fixed the issue!!!

Thank you so much 馃憤

No problem! :)

I hope the issue is fixed soon so that the gem works with rails 5.2.x.

Yes me too!

Are you running version 8.2.5 of the gem? I unwittingly was troubleshooting this on 8.2.4 and I even came to the same conclusion found in #534. Facepalm.

This was addressed in version 8.2.5, the problem was that an authenticity token wasn't being created for the form in the Sessions#new view. This was because we weren't using Rails form helpers to build the form, causing a failure when ActionController tries to check the authenticity token provided by the form (nil in this case).

Make sure the gem is up to date! Feel free to let me know if you feel like I've missed something.

@0ptimusrhyme 8.2.6 and still getting the issue :/ It happens on the redirect.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

resistorsoftware picture resistorsoftware  路  8Comments

sayduck-daniel picture sayduck-daniel  路  5Comments

charlesemarsh picture charlesemarsh  路  6Comments

arialblack14 picture arialblack14  路  5Comments

vfonic picture vfonic  路  4Comments