@@ -174,13 +174,26 @@ Display the current version of the package.
174174#### ` datacustomcode configure `
175175Configure credentials for connecting to Data Cloud.
176176
177+ ** Prerequisites:**
178+ - A [ connected app] ( #creating-a-connected-app ) with OAuth settings configured
179+ - For OAuth Tokens authentication: [ refresh token and core token] ( #obtaining-refresh-token-and-core-token )
180+
177181Options:
178182- ` --profile TEXT ` : Credential profile name (default: "default")
183+ - ` --auth-type TEXT ` : Authentication method (` oauth_tokens ` or ` username_password ` , default: ` oauth_tokens ` )
184+ - ` --login-url TEXT ` : Salesforce login URL
185+
186+ For Username/Password authentication:
179187- ` --username TEXT ` : Salesforce username
180188- ` --password TEXT ` : Salesforce password
181189- ` --client-id TEXT ` : Connected App Client ID
182190- ` --client-secret TEXT ` : Connected App Client Secret
183- - ` --login-url TEXT ` : Salesforce login URL
191+
192+ For OAuth Tokens authentication:
193+ - ` --client-id TEXT ` : Connected App Client ID
194+ - ` --client-secret TEXT ` : Connected App Client Secret
195+ - ` --refresh-token TEXT ` : OAuth refresh token (see [ Obtaining Refresh Token] ( #obtaining-refresh-token-and-core-token ) )
196+ - ` --core-token TEXT ` : (Optional) OAuth core/access token - if not provided, it will be obtained using the refresh token
184197
185198
186199#### ` datacustomcode init `
@@ -324,6 +337,71 @@ You can read more about Jupyter Notebooks here: https://jupyter.org/
324337
325338You now have all fields necessary for the ` datacustomcode configure ` command.
326339
340+ ### Obtaining Refresh Token and Core Token
341+
342+ If you're using OAuth Tokens authentication (instead of Username/Password), follow these steps to obtain your refresh token and core token (access token).
343+
344+ #### Step 1: Note Connected App Details
345+
346+ From your connected app, note down the following:
347+ - ** Client ID**
348+ - ** Client Secret**
349+ - ** Callback URL** (e.g., ` http://localhost:55555/callback ` )
350+
351+ #### Step 2: Obtain Authorization Code
352+
353+ 1 . Open a browser and navigate to the following URL (replace placeholders with your values):
354+
355+ ```
356+ <LOGIN_URL>/services/oauth2/authorize?response_type=code&client_id=<CLIENT_ID>&redirect_uri=<CALLBACK_URL>
357+ ```
358+
359+ 2 . After authenticating, you'll be redirected to your callback URL. The redirected URL will be in the form:
360+ ```
361+ <CALLBACK_URL>?code=<CODE>
362+ ```
363+
364+ 3 . Extract the ` <CODE> ` from the address bar. If the address bar doesn't show it, check the ** Network tab** in your browser's developer tools.
365+
366+ #### Step 3: Exchange Code for Tokens
367+
368+ Make a POST request to exchange the authorization code for tokens. You can use ` curl ` or Postman:
369+
370+ ``` bash
371+ curl --location --request POST ' <LOGIN_URL>/services/oauth2/token' \
372+ --header ' Content-Type: application/x-www-form-urlencoded' \
373+ --data-urlencode ' grant_type=authorization_code' \
374+ --data-urlencode ' code=<CODE>' \
375+ --data-urlencode ' client_id=<CLIENT_ID>' \
376+ --data-urlencode ' client_secret=<CLIENT_SECRET>' \
377+ --data-urlencode ' redirect_uri=<CALLBACK_URL>'
378+ ```
379+
380+ The response will be a JSON object containing:
381+
382+ ``` json
383+ {
384+ "access_token" : " <access_token>" ,
385+ "refresh_token" : " <refresh_token>" ,
386+ "signature" : " <signature>" ,
387+ "scope" : " refresh_token cdp_query_api api cdp_profile_api cdp_api full" ,
388+ "id_token" : " <id_token>" ,
389+ "instance_url" : " https://your-instance.my.salesforce.com" ,
390+ "id" : " https://login.salesforce.com/id/00DSB.../005SB..." ,
391+ "token_type" : " Bearer" ,
392+ "issued_at" : " 1767743916187"
393+ }
394+ ```
395+
396+ The key fields you need are:
397+ | Field | Description |
398+ | -------| -------------|
399+ | ` access_token ` | The ** core token** (also called access token) |
400+ | ` refresh_token ` | The ** refresh token** for obtaining new access tokens |
401+ | ` instance_url ` | Your Salesforce instance URL |
402+
403+ Use the ` refresh_token ` value when running ` datacustomcode configure ` with OAuth Tokens authentication.
404+
327405## Other docs
328406
329407- [ Troubleshooting] ( ./docs/troubleshooting.md )
0 commit comments