Module: SfCli::Sf::Org::Login
- Included in:
- Core
- Defined in:
- lib/sf_cli/sf/org/login.rb
Instance Method Summary collapse
-
#login_access_token(instance_url:, target_org: nil) ⇒ Object
Login to the org by access token.
-
#login_web(target_org: nil, instance_url: nil, browser: nil) ⇒ Object
Log in to a Salesforce org using the web server flow.
Instance Method Details
#login_access_token(instance_url:, target_org: nil) ⇒ Object
Note:
This method doesn’t support user interactive mode, so SF_ACCESS_TOKEN environment variable must be set before calling this method.
Login to the org by access token.
If you don’t set SF_ACCESS_TOKEN in the code, you have to set it outside of the script:
In Unix/mac
$ SF_ACCESS_TOKEN='xxxxxxxxxx'
$ ruby app_using_sfcli.rb
OR
$ SF_ACCESS_TOKEN='xxxxxxxxxx' ruby app_using_sfcli.rb
In Windows
> set SF_ACCESS_TOKEN=xxxxxxxxxx
> ruby app_using_sfcli.rb
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/sf_cli/sf/org/login.rb', line 49 def login_access_token(instance_url:, target_org: nil) flags = { :"instance-url" => instance_url, :"alias" => target_org, } switches = { :"no-prompt" => true, } action = __method__.to_s.tr('_', '-').sub('-', ' ') exec action, flags: flags, switches: switches, redirection: :null_stderr end |
#login_web(target_org: nil, instance_url: nil, browser: nil) ⇒ Object
Log in to a Salesforce org using the web server flow
14 15 16 17 18 19 20 21 22 |
# File 'lib/sf_cli/sf/org/login.rb', line 14 def login_web(target_org: nil, instance_url: nil, browser: nil) flags = { :"alias" => target_org, :"instance-url" => instance_url, :"browser" => browser, } action = __method__.to_s.tr('_', ' ') exec(action, flags: flags) end |