credentials

package
v2.0.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2019 License: MIT Imports: 4 Imported by: 30

README

Credentials

back

To access Salesforce APIs, there needs to be authentication between the client and the org. go-sfdc uses OAuth 2.0 and this package provides the credentials needed to authenticate.

The user is able to use the Providers that are part of this package, or implement one of their own. This allows for extendability beyond what is currently supported.

Currently, this package supports grant type of password OAuth flow. The package may or may not be support other flows in the future.

Examples

The following are some example(s) of creating credentials to be used when opening a session.

Password
creds := credentials.PasswordCredentials{
	URL:          "https://login.salesforce.com",
	Username:     "my.user@name.com",
	Password:     "greatpassword",
	ClientID:     "asdfnapodfnavppe",
	ClientSecret: "12312573857105",
}

config := sfdc.Configuration{
	Credentials: credentials.NewPasswordCredentials(creds),
	Client:      salesforceHTTPClient,
	Version:     44,
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Credentials

type Credentials struct {
	// contains filtered or unexported fields
}

Credentials is the structure that contains all of the information for creating a session.

func NewCredentials

func NewCredentials(provider Provider) (*Credentials, error)

NewCredentials will create a credential with the custom provider.

func NewPasswordCredentials

func NewPasswordCredentials(creds PasswordCredentials) (*Credentials, error)

NewPasswordCredentials will create a crendential with the password credentials.

func (*Credentials) Retrieve

func (creds *Credentials) Retrieve() (io.Reader, error)

Retrieve will return the reader for the HTTP request body.

func (*Credentials) URL

func (creds *Credentials) URL() string

URL is the URL base for the session endpoint.

type PasswordCredentials

type PasswordCredentials struct {
	URL          string
	Username     string
	Password     string
	ClientID     string
	ClientSecret string
}

PasswordCredentials is a structure for the OAuth credentials that are needed to authenticate with a Salesforce org.

URL is the login URL used, examples would be https://test.salesforce.com or https://login.salesforce.com

Username is the Salesforce user name for logging into the org.

Password is the Salesforce password for the user.

ClientID is the client ID from the connected application.

ClientSecret is the client secret from the connected application.

type Provider

type Provider interface {
	Retrieve() (io.Reader, error)
	URL() string
}

Provider is the interface that is able to provide the session creator with all of the valid information.

Retrieve will return the reader for the HTTP request body.

URL is the URL base for the session endpoint.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL