Skip to content

Commit

Permalink
Merge pull request #47 from k-capehart/update-get-access-token-docs
Browse files Browse the repository at this point in the history
update docs for GetAccessToken() and handle case where auth is nil
  • Loading branch information
k-capehart authored Jun 27, 2024
2 parents b226e8d + 99e13ff commit a92950b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

```
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion salesforce.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
}
5 changes: 5 additions & 0 deletions salesforce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2706,6 +2706,11 @@ func TestGetAccessToken(t *testing.T) {
sf: sf,
want: "1234",
},
{
name: "no_access_token",
sf: &Salesforce{},
want: "",
},
}

for _, tt := range tests {
Expand Down

0 comments on commit a92950b

Please sign in to comment.