2

GitHub recently released CodeSpaces which allows you to run VSCode in the cloud, which I believe the up coming Salesforce Code Builder will be based on.

I am trying to get it to work on my Chromebook, but I am struggling to authenticate with my dev hub.

Below are the steps completed so far:

  1. Enabled Codespaces on our GitHub account, under Organisations (free until Sept 10th 2021)
  2. Created a GitHub repo
  3. From the Code drop-down menu, and in the Codespaces tab, I've created a New Codespace
  4. Waiting a couple of moments for it to load
  5. Boom! it's working
  6. Installed the Salesforce Extension Pack
  7. Installed the Salesforce CLI using the Terminal using command npm install sfdx-cli --global
  8. Create a project using the command palette

Next I want to authenticate with my Dev Hub, using command palette, I run the usual command, and authenicate against my org.

But the redirect back goes to:

http://localhost:1717/OauthRedirect?code=XXXXXXXXXXXXXXXXX%3D%3D&state=XXXXXXXXXXXX

Looking in the hosted VSCode, it's created a port forward for port 1717 with a custom URL:

https://me-mycompany-my-codespace-test-9vxgvj9g29rq-1717.githubpreview.dev/

Therefore, I guess the OAuth redirect isn't making it back?

Any idea how to make this work?

3 Answers 3

1

You can do this via any of the below methods without making the port entry public,

  1. Create your own connected app in DevHub instead of using the default one that comes with the Salesforce CLI and have a redirect URL in the connected app equal to the codespace domain URL.

    sfdx auth:web:login -i <consumer key of your new connected app>

or

  1. Simply use Device login flow for the CodeSpaces. The advantage of this is you do not have create your own connected app for this one.

    sfdx auth:device:login

2

Workaround

  1. Right click on the port forwarding entry and Make Public
  2. Click on the globe icon
  3. Copy the public URL
  4. Use the public URL with the OAuth redirect /OauthRedirect?code=... without the 1717 port.

Port forwarding can be found in the Ports tab in the Panel or by clicking the Ports icon in the Status Bar

enter image description here

enter image description here

0

I caved and just used an sfdx-url from a non-GitHub Codespaces authorized environment 🤷‍♂️

echo "force://PlatformCLI::copiedSfdxUrl" > orgAlias.sfdxurl
sf org login sfdx-url -a orgAlias -f orgAlias.sfdxurl

Make sure not to commit the sfdxurl file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .