Cannot run shopify login with Shopify CLI (no browser). What is the workaround?

Solved

Cannot run shopify login with Shopify CLI (no browser). What is the workaround?

jam_chan
Shopify Partner
909 23 182

I've installed Shopify CLI to try theme app extension. But I am working remotely from my PC to Ubuntu 18.04 dev server. When I run Shopify login, CLI gives me a URL to paste on the browser. But the redirect URI in this URL starts with 127.0.0.1. The link showed the login screen but it failed after I clicked my account.

Even I can login, I am not sure if I can scaffold a theme app extension since my app is not created with CLI. 

I understand that Shopify wants to push all themes to upgrade to OS 2.0. My app is Python / Django. Now the CLI is installed with rbenv and >= Ruby 2.7. And it requires local development. Can you give me a less opinionated choice or workaround?

My app just uploads 4 liquid files to the theme. And the liquid files are using theme sections to make customizations. 

BYOB - Build Your Own Bundles, SPO - SEO App to research keywords & edit social link preview
Accepted Solution (1)
jam_chan
Shopify Partner
909 23 182

This is an accepted solution.

Just use python built-in webbrowser module to visit the link. 

BYOB - Build Your Own Bundles, SPO - SEO App to research keywords & edit social link preview

View solution in original post

Replies 11 (11)

FurnaceX
Shopify Partner
49 2 48

Did you figure this out? I'm trying to do the exact same thing.  I have ubuntu VM on AWS with no browser.  Thanks!

jam_chan
Shopify Partner
909 23 182

This is an accepted solution.

Just use python built-in webbrowser module to visit the link. 

BYOB - Build Your Own Bundles, SPO - SEO App to research keywords & edit social link preview
FurnaceX
Shopify Partner
49 2 48

I ended up creating a tunnel for port 3456 using Putty:

FurnaceX_0-1632019097684.png

 

NetDave
Shopify Partner
6 0 3

Do you use the command "shopify login"? If so , how does this solve the browser issue? Could you please explain it a bit further?

 

 

mmwasiel
Shopify Partner
2 0 4

Run ssh -N -L localhost:3456:localhost:3456 <username>@<ip of your cli server>

JecoubSamarita
Shopify Partner
1 0 2

Worked for me without using "-N". If you want to ssh tunnel the dev server also just use "ssh -L localhost:3456:localhost:3456 -L localhost:9292:localhost:9292 <user>@<server_ip>"

 

jam_chan
Shopify Partner
909 23 182

Is it still ok to use a Tunnel in Putty? I try the same way for CLI 3.x running npm run dev. Copy the login link to the browser. Chrome tells me log in successfully. But the CLI exits on its own. Anyone is trying CLI on a remote server?

BYOB - Build Your Own Bundles, SPO - SEO App to research keywords & edit social link preview
NetDave
Shopify Partner
6 0 3

Could you explain how to have the Shopify CLI open the that particular text editor? When I enter Shopify login, a text browser opens automatically in the text editor, so I can't solve the captcha, which requires javascript. Does python's browser solve the captcha issue?

 

Modestas
Shopify Partner
1 0 3

This is not correct and shouldn't be an accepted solution. The question indicates, that they are working remotely (which probably indicates SSH tunnel). The Python webbrowser module does not help, when going to the link from remote terminal. The login page still redirects to 127.0.0.1.

Misho
Shopify Partner
3 0 3

I was able to figure this out thanks to a post here: https://blog.klaudsol.com/how-to-run-shopify-cli-in-aws-cloud-9/

I was able to authenticate a Shopify partner account on "Ubuntu 22.04.3 LTS" AWS EC2 instance. Steps below:

1. Install Node.js and npm. I used Node Version Manager (Option 3 here)
2. Install Shopify CLI with theme: npm install -g @Shopify /cli @Shopify /theme
3. Check if it is installed: shopify version
4. Chose a folder and build app: npm init @Shopify /app@latest
5. Shopify App structure created successfully, and at this point you need to initiate a login to Shopify partner account and authenticate. Because I am creating an extension app I run: npm run shopify app generate extension
6. Wait for the "Auto-open timed out" message to appear after the banner:
To run this command, log in to Shopify Partners.

Misho_0-1700203658181.png Press any key to open the login page on your browser
Auto-open timed out. Open the login page: Log in to Shopify Partners ( http://accounts.shopify.com/oauth/authorize?client_id=.... )
7. Copy the full URL in the brackets after "Log in to Shopify Partners" text
8. Paste it in a browser on your local PC (preferably in a window already logged in to a Shopify partner account)
9. You will get a "This site can’t be reached 127.0.0.1 refused to connect." page. Copy the generated URL. It needs to have a URL starting with "http://127.0.0.1:3456/?code=...." . BTW generating the code did not work from the first time for me.
10. Open a new SSH session to your AWS EC2 instance. Paste the full URL in a wget command. Like: wget 'http://127.0.0.1:3456/?code=' . Do not forget the single quotes around the link.
11. Done. At the first SSH session screen you can see the authentication process finalizing.

kamal_sh
Shopify Partner
1 0 0

This method worked for me. Thanks a lot!