Module: SfCli::Sf::Org::Login

Defined in:
lib/sf_cli/sf/org/login.rb

Instance Method Summary collapse

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

Examples:

ENV['SF_ACCESS_TOKEN'] = 'xxxxxxxxxx'
sf.org. instance_url: 'https://hoge.bar.baz.salesforce.com'

Parameters:

  • target_org (Symbol, String) (defaults to: nil)

    an alias of paticular org, or username can be used

  • instance_url (String)

    URL of the instance that the org lives on.

See Also:



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/sf_cli/sf/org/login.rb', line 49

def (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

Login to the org by the browser.

Examples:

sf.org.
sf.org. target_org: :dev

Parameters:

  • target_org (Symbol, String) (defaults to: nil)

    an alias of paticular org, or username can be used

  • instance_url (String) (defaults to: nil)

    URL of the instance that the org lives on.

  • browser (Symbol, String) (defaults to: nil)

    browser in which to open the org.

See Also:



14
15
16
17
18
19
20
21
22
# File 'lib/sf_cli/sf/org/login.rb', line 14

def (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