session

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: 6 Imported by: 107

README

Session

back

The session is used to authenticate with Salesforce and retrieve the org's information. The session will be used by the API packages to properly access the Salesforce org. The credentials will need to be will be used to properly create the session.

Example

The following example demonstrates how to create a session.

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

if err != nil {
    fmt.Printf("error %v\n", err)
    return
}

config := sfdc.Configuration{
	Credentials: pwdCreds,
	Client:      http.DefaultClient,
	Version:     44,
}

session, err := session.Open(config)

if err != nil {
	fmt.Printf("Error %v\n", err)
	return
}

// access Salesforce APIs

Documentation

Overview

Package session provides handles creation of a Salesforce session

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clienter

type Clienter interface {
	Client() *http.Client
}

Clienter interface provides the HTTP client used by the the resources.

type InstanceFormatter

type InstanceFormatter interface {
	InstanceURL() string
	AuthorizationHeader(*http.Request)
	Clienter
}

InstanceFormatter is the session interface that formaters the session instance information used by the resources.

InstanceURL will return the Salesforce instance.

AuthorizationHeader will add the authorization to the HTTP request's header.

type ServiceFormatter

type ServiceFormatter interface {
	InstanceFormatter
	ServiceURL() string
}

ServiceFormatter is the session interface that formats the session for service resources.

ServiceURL provides the service URL for resources to user.

type Session

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

Session is the authentication response. This is used to generate the authroization header for the Salesforce API calls.

func Open

func Open(config sfdc.Configuration) (*Session, error)

Open is used to authenticate with Salesforce and open a session. The user will need to supply the proper credentials and a HTTP client.

func (*Session) AuthorizationHeader

func (session *Session) AuthorizationHeader(request *http.Request)

AuthorizationHeader will add the authorization to the HTTP request's header.

func (*Session) Client

func (session *Session) Client() *http.Client

Client returns the HTTP client to be used in APIs calls.

func (*Session) InstanceURL

func (session *Session) InstanceURL() string

InstanceURL will retuern the Salesforce instance from the session authentication.

func (*Session) ServiceURL

func (session *Session) ServiceURL() string

ServiceURL will return the Salesforce instance for the service URL.

Jump to

Keyboard shortcuts

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