diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..d87e3bd --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +SALESFORCE_CLIENT_ID=your_client_id_here +SALESFORCE_CLIENT_SECRET=your_client_secret_here diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 552f1c8..92e3c47 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,6 +12,9 @@ jobs: - name: install dependencies run: npm install - name: build + env: + SALESFORCE_CLIENT_ID: ${{ secrets.SALESFORCE_CLIENT_ID }} + SALESFORCE_CLIENT_SECRET: ${{ secrets.SALESFORCE_CLIENT_SECRET }} run: npm run make build_on_mac: @@ -27,6 +30,9 @@ jobs: - name: install dependencies run: npm install - name: build + env: + SALESFORCE_CLIENT_ID: ${{ secrets.SALESFORCE_CLIENT_ID }} + SALESFORCE_CLIENT_SECRET: ${{ secrets.SALESFORCE_CLIENT_SECRET }} run: npm run make build_on_win: @@ -39,4 +45,7 @@ jobs: - name: install dependencies run: npm install - name: build + env: + SALESFORCE_CLIENT_ID: ${{ secrets.SALESFORCE_CLIENT_ID }} + SALESFORCE_CLIENT_SECRET: ${{ secrets.SALESFORCE_CLIENT_SECRET }} run: npm run make diff --git a/.gitignore b/.gitignore index 87d5c8b..6619963 100644 --- a/.gitignore +++ b/.gitignore @@ -60,6 +60,8 @@ typings/ # dotenv environment variables file .env +.env.local +.env.*.local # parcel-bundler cache (https://parceljs.org/) .cache diff --git a/ReadMe.md b/ReadMe.md index b20b0cc..ab0336f 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -41,3 +41,64 @@ This project has no direct association with Salesforce except the use of the API ## Getting Involved If you would like to contribute to this project please feel invited to do so. Feel free to review open [issues](issues) and read the [contributing guide](contributing.md). + +## OAuth Setup + +Salesforce2Sql supports OAuth2 for connecting to Salesforce. To use it you will need to configure a Salesforce Connected App and then enter the client credentials into Salesforce2Sql. + +### Set Up OAuth in Salesforce2Sql + +1. Launch Salesforce2Sql. +2. Open the Preferences window. +3. Scroll to **Salesforce OAuth Settings**. +4. Paste in your **OAuth Client ID** and **OAuth Client Secret**. +5. Save your changes. + +The client secret is stored using Electron safeStorage so it stays encrypted on your local machine. + +After saving your credentials: + +1. Return to the main screen. +2. Click **Create New Connection**. +3. Leave **OAuth2** selected. +4. Confirm the login URL: + - Production orgs usually use `https://login.salesforce.com` + - Sandboxes usually use `https://test.salesforce.com` +5. Click **Connect**. +6. Sign in to Salesforce in the browser and approve access when prompted. + +### Set Up the Connected App in Salesforce + +If you do not already have a Connected App for this tool: + +1. In Salesforce, go to **Setup**. +2. Open **App Manager**. +3. Click **New Connected App**. +4. Enter the basic app details. +5. Enable **OAuth Settings**. +6. Set the callback URL to `http://localhost/completesetup`. +7. Add the OAuth scopes needed by Salesforce2Sql: + - **Access and manage your data (api)** + - **Access your basic information (id, profile, email, address, phone)** + - **Perform requests on your behalf at any time (refresh_token, offline_access)** + - **Provide access to your data via the Web (web)** +8. Save the Connected App. +9. After Salesforce finishes provisioning it, copy the **Consumer Key** and **Consumer Secret**. +10. Paste those values into the Salesforce2Sql Preferences window. + +### Development and CI Option + +For local development or CI, you can also provide the OAuth credentials through environment variables: + +```env +SALESFORCE_CLIENT_ID=your_client_id_here +SALESFORCE_CLIENT_SECRET=your_client_secret_here +``` + +If both stored preferences and environment variables are present, the environment variables are used. + +### Security Notes + +- Do not commit real OAuth secrets to the repository. +- Do not share production Connected App secrets in screenshots or issue comments. +- Use a sandbox Connected App for development whenever possible. diff --git a/app/index.html b/app/index.html index 2221378..d746b85 100644 --- a/app/index.html +++ b/app/index.html @@ -19,9 +19,7 @@