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
The `atlas-sdk-go` library uses Digest authentication.
3
+
The `atlas-sdk-go` library utilizes Digest authentication as its default authentication method.
4
4
You can [create an API key](https://www.mongodb.com/docs/atlas/configure-api-access/#create-an-api-key-in-an-organization) through the Atlas UI or the Atlas CLI.
5
5
6
-
To learn more about API authentication, see [Atlas Administration API Authentication](https://www.mongodb.com/docs/atlas/api/api-authentication).
6
+
To learn more about API authentication, refer to[Atlas Administration API Authentication](https://www.mongodb.com/docs/atlas/api/api-authentication).
7
7
8
-
### Use the Atlas Go SDK in Your Code
8
+
##Using the Atlas Go SDK in Your Code with Digest Authentication
9
9
10
-
Construct a new Atlas SDK client, then use the services on the client to
11
-
access different parts of the Atlas Admin API. For example:
10
+
To access different parts of the Atlas Admin API, construct a new Atlas SDK client and use its services. For example:
## (Preview) Using the Atlas Go SDK with Service Account Authentication
44
+
45
+
Atlas SDK Go provides OAuth Authentication using Service Accounts (currently available as a [Preview](https://www.mongodb.com/resources/beta-programs) feature)
46
+
A Service Account implements an OAuth [client_credentials](https://oauth.net/2/grant-types/client-credentials) grant.
47
+
For more information about feature please refer to [Service Account Public documentation.](https://www.mongodb.com/docs/atlas/api/service-accounts-overview/)
48
+
49
+
## OAuth Authentication
50
+
51
+
### Authenticating with OAuth ClientID and ClientSecret
52
+
53
+
### Admin API Authentication using Service Accounts
> NOTE: This method of initialization provides **No Ability to Revoke API**: once a token is issued, it cannot be invalidated until it expires.
83
+
84
+
### Specifying a Token Cache
85
+
86
+
In this example, we will demonstrate how to use the OAuth Client Credentials flow with a custom token cache.
87
+
The cache allows you to store OAuth tokens for reuse across application restarts, improving efficiency by reducing the number of token requests to the authorization server. This reduction in requests also minimizes the impact of OAuth Token Limits and Rate Limiting.
Revocation invalidates an OAuth token before its expiration date. This effectively "logs out" the current OAuth client and allows you to configure a new client.
158
+
159
+
```go
160
+
// Sounding code omitted for brevity
161
+
err:= tokenSource.RevokeToken()
162
+
if err != nil {
163
+
log.Fatalf("Error: %v", err)
164
+
}
165
+
```
166
+
167
+
### Creating a Custom Transport
168
+
169
+
You can create a custom transport to inject the OAuth token into HTTP requests.
170
+
The `OAuthCustomHTTPTransport` provides an `UnderlyingTransport` field that specifies the transport to use for requests.
0 commit comments