Skip to content

Commit 62414d4

Browse files
committed
docs: add authentication section to readme.
Document the new and existing authentication methods.
1 parent 5196849 commit 62414d4

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,45 @@ func main() {
5757
fmt.Printf("%+v\n", resp)
5858
}
5959
```
60+
61+
### Authentication
62+
63+
The client supports several authentication methods.
64+
65+
1. Explicit configuration: Set `Host` and `Token` in the `Config`:
66+
67+
```go
68+
cfg := oxide.Config{
69+
Host: "https://api.oxide.computer",
70+
Token: "oxide-abc123",
71+
}
72+
```
73+
74+
1. Environment variables: Set `OXIDE_HOST` and `OXIDE_TOKEN`:
75+
76+
```bash
77+
export OXIDE_HOST="https://api.oxide.computer"
78+
export OXIDE_TOKEN="oxide-abc123"
79+
```
80+
81+
1. Oxide profile: Use a profile from the Oxide config file:
82+
- Set `Profile` in the `Config`:
83+
```go
84+
cfg := oxide.Config{
85+
Profile: "my-profile",
86+
}
87+
```
88+
- Or set the `OXIDE_PROFILE` environment variable:
89+
```bash
90+
export OXIDE_PROFILE="my-profile"
91+
```
92+
93+
1. Default profile: Use the default profile from the Oxide config file:
94+
```go
95+
cfg := oxide.Config{
96+
UseDefaultProfile: true,
97+
}
98+
```
99+
100+
When using profiles, the client reads from the Oxide CLI configuration files located at `$HOME/.config/oxide/credentials.toml` (or a custom directory via `Config.ConfigDir`).
101+
Values defined in `Config` have higher precedence and override environment variables. Configuring both profile and host/token authentication is disallowed and will return an error from oxide.NewClient, as well configuring both a profile and the default profile.

0 commit comments

Comments
 (0)