This Go script queries your Salesforce org and outputs a JSON file that maps:
- Report Folders
- Name
- Access Type (Public, Private, Shared)
- Shared Users
- Contained Reports
- Report Name
- Report Owner
It uses the Salesforce REST and Tooling APIs to pull folder structure, access control, and report metadata into a single, human-readable file.
- Fetches all
Reportfolders via SOQL - Retrieves
FolderSharerecords using the Tooling API - Resolves
UserIdreferences to actual names - Lists all reports per folder, including the report owner
- Outputs a structured JSON file for easy auditing or visualization
report_folders.json:
[
{
"name": "Sales_Team",
"access_type": "Public",
"shared_with": ["Alice Johnson", "Bob Lee"],
"reports": [
{
"name": "Q1 Pipeline",
"owner": "Alice Johnson"
},
...
]
},
...
]-
Go 1.18+
-
Salesforce API access with:
- OAuth bearer token (with
View Setup and Configurationpermission) - REST and Tooling API enabled
- OAuth bearer token (with
- Clone or copy this Gist locally.
- Open
main.go. - Set the following constants:
const (
instanceURL = "https://yourInstance.salesforce.com" // e.g. https://na85.salesforce.com
token = "YOUR_ACCESS_TOKEN" // from OAuth flow or Workbench
)- Run the script:
go run main.goThe script will create a file:
report_folders.json
Use this to review sharing access, audit report ownership, or feed into other workflows.
- Support
.envor CLI flags for auth - Resolve Groups and Roles in
FolderShare - Add
Dashboardsupport - Export as CSV or HTML
Do not commit or share your OAuth token. Use environment variables or secret managers for secure usage in production environments.
Built by Pat Sullivan (TechTended), based on needs for full auditability of Salesforce reporting access patterns across GTM teams.