mirror of
https://github.com/LukeHagar/developer.sailpoint.com.git
synced 2025-12-07 12:27:47 +00:00
210 lines
6.6 KiB
Plaintext
210 lines
6.6 KiB
Plaintext
---
|
|
id: go-sdk
|
|
title: Go SDK
|
|
pagination_label: Go SDK
|
|
sidebar_label: Golang
|
|
sidebar_position: 2
|
|
sidebar_class_name: gosdk
|
|
keywords: ['go', 'golang', 'sdk']
|
|
description: Easy ISC development in Golang SDK.
|
|
slug: /tools/sdk/go
|
|
tags: ['SDK', 'Software Development Kit']
|
|
---
|
|
|
|
Read this guide to learn how to use the Go SDK. The Go SDK has some pre-built code examples you can use to learn how to build tools that can interact with IdentityNow.
|
|
|
|
## Requirements
|
|
|
|
You need the following to use the Go SDK:
|
|
|
|
- Golang version 1.18 or above. You can download it [here](https://go.dev/dl/). You can use `go version` to check your version.
|
|
|
|
- Your tenant name in IdentityNow. To learn how to find it, refer to [Getting Started](/docs/api/getting-started#find-your-tenant-name). The SDK will use this tenant name to connect to your IdentityNow instance.
|
|
|
|
- A PAT with a client secret and ID. To learn how to create one in ISC, refer to [Personal Access Tokens](https://documentation.sailpoint.com/saas/help/common/api_keys.html#generating-a-personal-access-token). The SDK will use this PAT to authenticate with the SailPoint APIs.
|
|
|
|
|
|
## Setup
|
|
|
|
<details>
|
|
<summary>CLI Assisted <em>(Recommended)</em></summary>
|
|
|
|
The SailPoint CLI offers a few commands that will allow you to quickly get started with the Go SDK. To learn how to install and use the SailPoint CLI, refer to [SailPoint CLI](https://developer.sailpoint.com/idn/tools/cli#get-the-cli).
|
|
|
|
Once the CLI is installed and configured, run this command to create a new Go project with the Go SDK:
|
|
|
|
```bash
|
|
sail sdk init golang go-example
|
|
```
|
|
|
|
Running the command will create the structure for your project:
|
|
|
|
```text
|
|
|-- go-example
|
|
| |-- go.mod
|
|
| |-- go.sum
|
|
| |-- sdk.go
|
|
```
|
|
|
|
Navigate into your project folder and run this command to install the required dependencies:
|
|
|
|
```bash
|
|
go mod tidy
|
|
```
|
|
|
|
The SDK is now installed. To learn how to configure the SDK, refer to the [Configure section](#configure).
|
|
|
|
|
|
</details>
|
|
|
|
<details>
|
|
<summary>Manual Installation</summary>
|
|
|
|
To begin your go project, you will need to create a directory for your project.
|
|
|
|
To create a project directory, run this command:
|
|
|
|
```bash
|
|
mkdir golang-example
|
|
```
|
|
|
|
Then run this command to change into your project directory:
|
|
|
|
```bash
|
|
cd golang-example
|
|
```
|
|
|
|
To initialize your project and create the `go.mod` file, run this command in your project directory:
|
|
|
|
```go
|
|
go mod init github.com/github-repo-name/golang-example
|
|
```
|
|
|
|
You will edit this file to add the SailPoint SDK to your project.
|
|
|
|
To install the SailPoint SDK, run this command:
|
|
|
|
```go
|
|
go get github.com/sailpoint-oss/golang-sdk/v2
|
|
```
|
|
|
|
The SDK is now installed. To learn how to configure the SDK, refer to the [Configure section](#configure).
|
|
|
|
</details>
|
|
|
|
## Configure
|
|
|
|
You must provide configuration to the SDK so that it can authenticate to your SailPoint tenant and make API calls. To do so, you can use a configuration file, "config.json", or environment variables.
|
|
|
|
### Configuration File
|
|
|
|
The SDK requires a configuration file to be named "config.json". Within the file, provide these key/value pairs: `ClientId`, `ClientSecret`, `BaseURL`.
|
|
|
|
<details>
|
|
<summary>CLI Assisted <em>(Recommended)</em></summary>
|
|
The SailPoint CLI offers a command to generate the "config.json" file with your currently configured CLI credentials.
|
|
|
|
```bash
|
|
sail sdk init config
|
|
```
|
|
|
|
If you have multiple environments configured with the CLI, you can pass an additional parameter to state the environment you wish to create a "config.json" for.
|
|
|
|
To pass an additional parameter that states the environment you want to configure, run this command:
|
|
|
|
```bash
|
|
sail sdk init config --env devrel
|
|
```
|
|
|
|
#### Example "config.json"
|
|
|
|
```json
|
|
{
|
|
"ClientId": "g0567b766b413b22c05c66e75d532f1b",
|
|
"ClientSecret": "cabd0e950a7230b63c1ff45be33fb22065b382b6251a73c61177a8bb5482fcc7",
|
|
"BaseURL": "https://[tenant].api.identitynow.com"
|
|
}
|
|
```
|
|
|
|
</details>
|
|
|
|
<details>
|
|
<summary>Manual Configuration</summary>
|
|
|
|
Create a file named "config.json", and provide these key/value pairs: `ClientId`, `ClientSecret`, `BaseURL`.
|
|
|
|
#### Example "config.json"
|
|
|
|
```json
|
|
{
|
|
"ClientId": "g0567b766b413b22c05c66e75d532f1b",
|
|
"ClientSecret": "cabd0e950a7230b63c1ff45be33fb22065b382b6251a73c61177a8bb5482fcc7",
|
|
"BaseURL": "https://[tenant].api.identitynow.com"
|
|
}
|
|
```
|
|
|
|
</details>
|
|
|
|
:::warning
|
|
Please ensure this file is ignored in your version control system (ex. .gitignore for git)
|
|
:::
|
|
|
|
### Environment variable configuration
|
|
|
|
You can also store your configuration in environment variables.
|
|
|
|
To get your environment variables to persist across terminal sessions, add these exports to your shell profile, something like `~/.bash_profile`.
|
|
|
|
import Tabs from '@theme/Tabs';
|
|
import TabItem from '@theme/TabItem';
|
|
|
|
<Tabs>
|
|
<TabItem value="linux_mac" label="Linux/Mac" default>
|
|
|
|
```bash
|
|
export SAIL_BASE_URL=https://[tenant].api.identitynow.com
|
|
export SAIL_CLIENT_ID=[clientID]
|
|
export SAIL_CLIENT_SECRET=[clientSecret]
|
|
```
|
|
|
|
</TabItem>
|
|
<TabItem value="windows" label="Windows PowerShell">
|
|
|
|
```bash
|
|
$env:SAIL_BASE_URL=https://[tenant].api.identitynow.com
|
|
$env:SAIL_CLIENT_ID=[clientID]
|
|
$env:SAIL_CLIENT_SECRET=[clientSecret]
|
|
```
|
|
|
|
To get your environment variables to persist across PowerShell sessions, run these commands instead:
|
|
|
|
```powershell
|
|
[System.Environment]::SetEnvironmentVariable('SAIL_BASE_URL','https://[tenant].api.identitynow.com')
|
|
[System.Environment]::SetEnvironmentVariable('SAIL_CLIENT_ID','[clientID]')
|
|
[System.Environment]::SetEnvironmentVariable('SAIL_CLIENT_SECRET','[clientSecret]')
|
|
```
|
|
|
|
</TabItem>
|
|
</Tabs>
|
|
|
|
## Getting Support
|
|
|
|
To get support for the Go SDK, please see our GitHub page, https://github.com/sailpoint-oss/golang-sdk.
|
|
|
|
To submit a bug report, please [click here](https://github.com/sailpoint-oss/golang-sdk/issues/new?assignees=&labels=bug&template=bug-report.md).
|
|
|
|
To submit a feature request, please [click here](https://github.com/sailpoint-oss/golang-sdk/issues/new?assignees=&labels=enhancement&template=feature-request.md)
|
|
|
|
## Contribute
|
|
|
|
Do you have an idea to help improve the Go SDK? You can contribute directly!
|
|
|
|
Before you contribute, you must sign our [CLA](https://cla-assistant.io/sailpoint-oss/golang-sdk) and read the [Contribution Guidelines](https://github.com/sailpoint-oss/developer.sailpoint.com/blob/main/CONTRIBUTING.md).
|
|
|
|
## Discuss
|
|
|
|
You can use this SDK to build new tools that extend your ISC platform and improve experiences across your organization. Use this guide to get started, and if you have questions, don't hesitate to reach out on the SailPoint Developer Community forum at https://developer.sailpoint.com/discuss!
|
|
|
|
## Getting Started
|
|
|
|
To get started using the SDK, refer to the [Getting Started Guide](./getting-started.md). |