-
Notifications
You must be signed in to change notification settings - Fork 2
sf cli auth #72
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
sf cli auth #72
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,10 @@ Use of this project with Salesforce is subject to the [TERMS OF USE](./TERMS_OF_ | |
| - JDK 17 | ||
| - Docker support like [Docker Desktop](https://docs.docker.com/desktop/) | ||
| - A salesforce org with some DLOs or DMOs with data and this feature enabled (it is not GA) | ||
| - An [External Client App](#creating-an-external-client-app) | ||
| - **One of the following** for authentication: | ||
| - A Salesforce org already authenticated via the [Salesforce CLI](https://developer.salesforce.com/tools/salesforcecli) | ||
| (simplest — no External Client App needed) | ||
| - An [External Client App](#creating-an-external-client-app) configured with OAuth settings | ||
|
|
||
| ## Installation | ||
| The SDK can be downloaded directly from PyPI with `pip`: | ||
|
|
@@ -65,6 +68,13 @@ datacustomcode configure | |
| datacustomcode run ./payload/entrypoint.py | ||
| ``` | ||
|
|
||
| > [!TIP] | ||
| > **Already using the Salesforce CLI?** If you have authenticated an org with `sf org login web | ||
| > --alias myorg`, you can skip `datacustomcode configure` entirely: | ||
| > ```zsh | ||
| > datacustomcode run ./payload/entrypoint.py --sf-cli-org myorg | ||
| > ``` | ||
|
|
||
| > [!IMPORTANT] | ||
| > The example entrypoint.py requires a `Account_std__dll` DLO to be present. And in order to deploy the script (next step), the output DLO (which is `Account_std_copy__dll` in the example entrypoint.py) also needs to exist and be in the same dataspace as `Account_std__dll`. | ||
|
|
||
|
|
@@ -183,17 +193,19 @@ Options: | |
| - `--auth-type TEXT`: Authentication method (default: `oauth_tokens`) | ||
| - `oauth_tokens` - OAuth tokens with refresh_token | ||
| - `client_credentials` - Server-to-server using client_id/secret only | ||
| - `--login-url TEXT`: Salesforce login URL | ||
|
|
||
| For OAuth Tokens authentication: | ||
| - `--client-id TEXT`: External Client App Client ID | ||
| - `--client-secret TEXT`: External Client App Client Secret | ||
| - `--refresh-token TEXT`: OAuth refresh token (see [Obtaining Refresh Token](#obtaining-refresh-token-and-core-token)) | ||
| - `--core-token TEXT`: (Optional) OAuth core/access token - if not provided, it will be obtained using the refresh token | ||
| You will be prompted for the following depending on auth type: | ||
|
|
||
| *Common to all auth types:* | ||
| - **Login URL**: Salesforce login URL | ||
| - **Client ID**: External Client App Client ID | ||
|
|
||
| *For OAuth Tokens authentication:* | ||
| - **Client Secret**: External Client App Client Secret | ||
| - **Redirect URI**: OAuth redirect URI | ||
|
|
||
| For Client Credentials authentication (server-to-server): | ||
| - `--client-id TEXT`: External Client App Client ID | ||
| - `--client-secret TEXT`: External Client App Client Secret | ||
| *For Client Credentials authentication:* | ||
| - **Client Secret**: External Client App Client Secret | ||
|
|
||
| ##### Using Environment Variables (Alternative) | ||
|
|
||
|
|
@@ -255,6 +267,9 @@ Options: | |
| - `--config-file TEXT`: Path to configuration file | ||
| - `--dependencies TEXT`: Additional dependencies (can be specified multiple times) | ||
| - `--profile TEXT`: Credential profile name (default: "default") | ||
| - `--sf-cli-org TEXT`: Salesforce CLI org alias or username (e.g. `dev1`). Fetches | ||
| credentials via `sf org display` — no `datacustomcode configure` step needed. | ||
| Takes precedence over `--profile` if both are supplied. | ||
|
|
||
|
|
||
| #### `datacustomcode zip` | ||
|
|
@@ -277,7 +292,7 @@ Options: | |
| - `--version TEXT`: Version of the transformation job (default: "0.0.1") | ||
| - `--description TEXT`: Description of the transformation job (default: "") | ||
| - `--network TEXT`: docker network (default: "default") | ||
| - `--cpu-size TEXT`: CPU size for the deployment (default: "CPU_XL"). Available options: CPU_L(Large), CPU_XL(Extra Large), CPU_2XL(2X Large), CPU_4XL(4X Large) | ||
| - `--cpu-size TEXT`: CPU size for the deployment (default: `CPU_2XL`). Available options: CPU_L(Large), CPU_XL(Extra Large), CPU_2XL(2X Large), CPU_4XL(4X Large) | ||
|
|
||
|
|
||
| ## Docker usage | ||
|
|
@@ -365,6 +380,54 @@ You can read more about Jupyter Notebooks here: https://jupyter.org/ | |
|
|
||
| You now have all fields necessary for the `datacustomcode configure` command. | ||
|
|
||
| ### Using the Salesforce CLI for authentication | ||
|
|
||
| The [Salesforce CLI](https://developer.salesforce.com/tools/salesforcecli) (`sf`) lets you authenticate an org once and then reference it by alias across tools — including this SDK via `--sf-cli-org`. | ||
|
|
||
| #### Installing the Salesforce CLI | ||
|
|
||
| Follow the [official install guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_install_cli.htm), or use a package manager: | ||
|
|
||
| ```zsh | ||
| # macOS (Homebrew) | ||
| brew install sf | ||
|
|
||
| # npm (all platforms) | ||
| npm install --global @salesforce/cli | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Want to make sure I'm following- are both of these needed? Or as a macOS user, only brew install is needed?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally installed via npm and didn't even know brew was a thing until later. You are correct however when you say you only need one way or the other. |
||
| ``` | ||
|
|
||
| Verify the install: | ||
| ```zsh | ||
| sf --version | ||
| ``` | ||
|
|
||
| #### Authenticating an org | ||
|
|
||
| **Browser-based (recommended for developer orgs and sandboxes):** | ||
| ```zsh | ||
| # Production / Developer Edition | ||
| sf org login web --alias myorg | ||
|
|
||
| # Sandbox | ||
| sf org login web --alias mysandbox --instance-url https://test.salesforce.com | ||
|
|
||
| # Custom domain | ||
| sf org login web --alias myorg --instance-url https://mycompany.my.salesforce.com | ||
| ``` | ||
|
|
||
| Each command opens a browser tab. After you log in and approve access, the CLI stores the session locally. | ||
|
|
||
| **Verify the stored org and confirm the alias:** | ||
| ```zsh | ||
| sf org list | ||
| sf org display --target-org myorg | ||
| ``` | ||
|
|
||
| Once authenticated, pass the alias directly to `datacustomcode run`: | ||
| ```zsh | ||
| datacustomcode run ./payload/entrypoint.py --sf-cli-org myorg | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we thinking about this in phases? I could see us wanting to utilize SF CLI as the main/default option, if not even the only option in time. Did you consider saving the SF CLI org ailas in one of this CLI's config locations - that way
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting idea and I did not consider this approach as the --profile doesn't work this way either. I will create a ticket to implement something like this in a future update. |
||
| ``` | ||
|
|
||
| ### Obtaining Refresh Token and Core Token | ||
|
|
||
| If you're using OAuth Tokens authentication, the initial configure will retrieve and store tokens. Run `datacustomcode auth` to refresh these when they expire. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you seen if/how this will work with jupyter notebook?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not. What I can say is this --sf-cli-org flag is in addition to what we already have. Everything else continues to work.