diff --git a/README.md b/README.md index 8e6222c..2a9c738 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,17 @@ A REST API wrapper for interacting with Salesforce using the Go programming lang - Read the [Salesforce REST API documentation](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_list.htm) - Read the [Golang documentation](https://go.dev/doc/) +## Table of Contents +- [Installation](#installation) +- [Authentication](#authentication) +- [SOQL](#soql) +- [SObject Single Record Operations](#sobject-single-record-operations) +- [SObject Collections](#sobject-collections) +- [Composite Requests](#composite-requests) +- [Bulk v2](#bulk-v2) +- [Other](#other) +- [Contributing](#contributing) + ## Installation ``` @@ -93,6 +104,16 @@ if err != nil { } ``` +### GetAccessToken() + +`func (sf *Salesforce) GetAccessToken() string` + +Returns the current session's Access Token as a string. + +```go +fmt.Println(sf.GetAccessToken()) +``` + ## SOQL Query Salesforce records diff --git a/salesforce.go b/salesforce.go index 2320f04..071aede 100644 --- a/salesforce.go +++ b/salesforce.go @@ -603,5 +603,8 @@ func (sf *Salesforce) GetJobResults(bulkJobId string) (BulkJobResults, error) { } func (sf *Salesforce) GetAccessToken() string { - return sf.auth.AccessToken + if sf.auth != nil { + return sf.auth.AccessToken + } + return "" } diff --git a/salesforce_test.go b/salesforce_test.go index 574fd66..916d3ef 100644 --- a/salesforce_test.go +++ b/salesforce_test.go @@ -2706,6 +2706,11 @@ func TestGetAccessToken(t *testing.T) { sf: sf, want: "1234", }, + { + name: "no_access_token", + sf: &Salesforce{}, + want: "", + }, } for _, tt := range tests {