You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+42Lines changed: 42 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,3 +57,45 @@ func main() {
57
57
fmt.Printf("%+v\n", resp)
58
58
}
59
59
```
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 OxideCLI 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