Browse Source

[review] [YDB] Check "recipes-for-nodejs-sdk-auth" translate

Ключи:
potapenko-k 2 years ago
parent
commit
2b6e74e191

+ 8 - 14
ydb/docs/en/core/reference/ydb-sdk/_includes/auth.md

@@ -31,12 +31,12 @@ You can click any of the methods below to go to the source code of an example in
 
    | Mode | Package | Method |
    ----- | ----- | ----
-   | Anonymous | [ydb-go-sdk/v3](https://github.com/ydb-platform/ydb-go-sdk/) | [ydb.WithAnonymousCredentials()](https://github.com/ydb-platform/ydb-go-examples/tree/master/auth/anonymous_credentials)
-   | User+Password | [ydb-go-sdk/v3](https://github.com/ydb-platform/ydb-go-sdk/) | [ydb.WithStaticCredentials(user, password)](https://github.com/ydb-platform/ydb-go-examples/tree/master/auth/static_credentials)
-   | Access Token | [ydb-go-sdk/v3](https://github.com/ydb-platform/ydb-go-sdk/) | [ydb.WithAccessTokenCredentials(token)](https://github.com/ydb-platform/ydb-go-examples/tree/master/auth/access_token_credentials)
-   | Metadata | [ydb-go-yc](https://github.com/ydb-platform/ydb-go-yc/) | [yc.WithMetadataCredentials(ctx)](https://github.com/ydb-platform/ydb-go-examples/tree/master/auth/metadata_credentials)
-   | Service Account Key | [ydb-go-yc](https://github.com/ydb-platform/ydb-go-yc/) | [yc.WithServiceAccountKeyFileCredentials(key_file)](https://github.com/ydb-platform/ydb-go-examples/tree/master/auth/service_account_credentials)
-   | Determined by environment variables | [ydb-go-sdk-auth-environ](https://github.com/ydb-platform/ydb-go-sdk-auth-environ/) | [environ.WithEnvironCredentials(ctx)](https://github.com/ydb-platform/ydb-go-examples/tree/master/auth/environ)
+   | Anonymous | [ydb-go-sdk/v3](https://github.com/ydb-platform/ydb-go-sdk/) | [ydb.WithAnonymousCredentials()](https://github.com/ydb-platform/ydb-go-examples/tree/master/auth/anonymous_credentials) |
+   | Access Token | [ydb-go-sdk/v3](https://github.com/ydb-platform/ydb-go-sdk/) | [ydb.WithAccessTokenCredentials(token)](https://github.com/ydb-platform/ydb-go-examples/tree/master/auth/access_token_credentials) |
+   | Metadata | [ydb-go-yc](https://github.com/ydb-platform/ydb-go-yc/) | [yc.WithMetadataCredentials(ctx)](https://github.com/ydb-platform/ydb-go-examples/tree/master/auth/metadata_credentials) |
+   | Service Account Key | [ydb-go-yc](https://github.com/ydb-platform/ydb-go-yc/) | [yc.WithServiceAccountKeyFileCredentials(key_file)](https://github.com/ydb-platform/ydb-go-examples/tree/master/auth/service_account_credentials) |
+   | Static Credentials | [ydb-go-sdk/v3](https://github.com/ydb-platform/ydb-go-sdk/) | [ydb.WithStaticCredentials(user, password)](https://github.com/ydb-platform/ydb-go-examples/tree/master/auth/static_credentials) |
+   | Determined by environment variables | [ydb-go-sdk-auth-environ](https://github.com/ydb-platform/ydb-go-sdk-auth-environ/) | [environ.WithEnvironCredentials(ctx)](https://github.com/ydb-platform/ydb-go-examples/tree/master/auth/environ) |
 
 - Java
 
@@ -50,19 +50,13 @@ You can click any of the methods below to go to the source code of an example in
 
 - Node.js
 
-   ```js
-   import { AnonymousAuthService, TokenAuthService,
-     MetadataAuthService, getSACredentialsFromJson,
-     getCredentialsFromEnv } from 'ydb-sdk';
-   ```
-
    | Mode | Method |
    ----- | -----
    | Anonymous | [AnonymousAuthService()](https://github.com/ydb-platform/ydb-nodejs-sdk/tree/main/examples/auth/anonymous-credentials) |
    | Access Token | [TokenAuthService( accessToken, database )](https://github.com/ydb-platform/ydb-nodejs-sdk/tree/main/examples/auth/access-token-credentials) |
    | Metadata | [MetadataAuthService( database )](https://github.com/ydb-platform/ydb-nodejs-sdk/tree/main/examples/auth/metadata-credentials) |
    | Service Account Key | [getSACredentialsFromJson( saKeyFile )](https://github.com/ydb-platform/ydb-nodejs-sdk/tree/main/examples/auth/service-account-credentials) |
-   | User+Password | [StaticCredentialsAuthService( user, password, endpoint )](https://github.com/ydb-platform/ydb-nodejs-sdk/tree/main/examples/auth/static-credentials) |
+   | Static Credentials | [StaticCredentialsAuthService( user, password, endpoint )](https://github.com/ydb-platform/ydb-nodejs-sdk/tree/main/examples/auth/static-credentials) |
    | Determined by environment variables | [getCredentialsFromEnv( entryPoint, database, logger )](https://github.com/ydb-platform/ydb-nodejs-sdk/tree/main/examples/auth/environ) |
 
 - Rust
@@ -74,7 +68,7 @@ You can click any of the methods below to go to the source code of an example in
    | Metadata | ydb::GCEMetadata, ydb::YandexMetadata |
    | Service Account Key | not supported |
    | Determined by environment variables | not supported |
-   | Execution of an external command | ydb.CommandLineYcToken (for example, for authentication using a {{ yandex-cloud }} [IAM token]{% if lang == "ru"%}(https://cloud.yandex.ru/docs/iam/concepts/authorization/iam-token){% endif %}{% if lang == "en" %}(https://cloud.yandex.com/en/docs/iam/concepts/authorization/iam-token){% endif %} from the developer's desktop ```ydb::CommandLineYcToken.from_cmd("yc iam create-token")```) |
+   | Execution of an external command | ydb.CommandLineYcToken (for example, for authentication using a {{ yandex-cloud }} [IAM token]{% if lang == "ru"%}(https://cloud.yandex.ru/docs/iam/concepts/authorization/iam-token){% endif %}{% if lang == "en" %}(https://cloud.yandex.com/en/docs/iam/concepts/authorization/iam-token){% endif %} from the developer's computer ```ydb::CommandLineYcToken.from_cmd("yc iam create-token")```) |
 
 {% endlist %}
 

+ 2 - 2
ydb/docs/en/core/reference/ydb-sdk/feature-parity.md

@@ -1,6 +1,6 @@
 # Comparison of SDK features
 
-| Feature | C\+\+ | Python | Go | Java | Node.js | C# | Rust | PHP |
+| Feature | C\+\+ | Python | Go | Java | NodeJS | C# | Rust | PHP |
 |:---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
 | SSL/TLS support (system certificates) | \+ | \+ | \+ | \+ | \+ | \+ | \+ |
 | SSL/TLS support (custom certificates) | \+ | \+ | \+ | \+ | \+ | \- |
@@ -22,7 +22,7 @@
 | Load balancing across all nodes of all local DCs | \+ | \+ | \+ | ? | \- | \- | \- |
 | **Credentials providers** |
 | Anonymous (default) | \+ | \+ | \+ | \+ | \+ | ? | \+ |
-| Static (user - password) | \+ | \+ | \+ | \+ | \+ | \- | \- |
+| Static (user - password) | \+ | \+ | \+ | \+ | \- | \- | \- |
 | Token: IAM, OAuth | \+ | \+ | \+ | \+ | \+ | \+ | \+ |
 | Service account (Yandex.Cloud specific) | \+ | \+ | \+ | \+ | \+ | \+ | \- |
 | Metadata (Yandex.Cloud specific) | \+ | \+ | \+ | \+ | \+ | \+ | \+ |

+ 96 - 101
ydb/docs/en/core/reference/ydb-sdk/recipes/auth-access-token.md

@@ -8,118 +8,113 @@ Below are examples of the code for authentication using a token in different {{
 
 - Go (native)
 
-   ```go
-   package main
-
-   import (
-     "context"
-     "os"
-
-     "github.com/ydb-platform/ydb-go-sdk/v3"
-   )
-
-   func main() {
-     ctx, cancel := context.WithCancel(context.Background())
-     defer cancel()
-     db, err := ydb.Open(ctx,
-       os.Getenv("YDB_CONNECTION_STRING"),
-       ydb.WithAccessTokenCredentials(os.Getenv("YDB_TOKEN")),
-     )
-     if err != nil {
-       panic(err)
-     }
-     defer db.Close(ctx)
-     ...
-   }
-   ```
+  ```go
+    package main
+
+    import (
+      "context"
+      "os"
+      
+      "github.com/ydb-platform/ydb-go-sdk/v3"
+    )
+
+  func main() {
+    ctx, cancel := context.WithCancel(context.Background())
+    defer cancel()
+    db, err := ydb.Open(ctx,
+      os.Getenv("YDB_CONNECTION_STRING"),
+      ydb.WithAccessTokenCredentials(os.Getenv("YDB_TOKEN")),
+    )
+    if err != nil {
+      panic(err)
+    }
+    defer db.Close(ctx)
+    ...
+  }
+  ```
 
 - Go (database/sql)
 
-   {% cut "If you use a connector to create a connection to {{ ydb-short-name }}" %}
-
-   ```go
-   package main
-
-   import (
-     "context"
-     "database/sql"
-     "os"
-
-     "github.com/ydb-platform/ydb-go-sdk/v3"
-   )
-
-   func main() {
-     ctx, cancel := context.WithCancel(context.Background())
-     defer cancel()
-     nativeDriver, err := ydb.Open(ctx,
-       os.Getenv("YDB_CONNECTION_STRING"),
-       ydb.WithAccessTokenCredentials(os.Getenv("YDB_TOKEN")),
-     )
-     if err != nil {
-       panic(err)
-     }
-     defer nativeDriver.Close(ctx)
-     connector, err := ydb.Connector(nativeDriver)
-     if err != nil {
-       panic(err)
-     }
-     db := sql.OpenDB(connector)
-     defer db.Close()
-     ...
-   }
-   ```
-
-   {% endcut %}
-
-   {% cut "If you use a connection string" %}
-
-   ```go
-   package main
-
-   import (
-     "context"
-     "database/sql"
-     "os"
-
-     _ "github.com/ydb-platform/ydb-go-sdk/v3"
-   )
-
-   func main() {
-     db, err := sql.Open("ydb", "grpcs://localohost:2135/local?token="+os.Getenv("YDB_TOKEN"))
-     if err != nil {
-       panic(err)
-     }
-     defer db.Close()
-     ...
-   }
-   ```
-
-   {% endcut %}
+  {% cut "If you use a connector to create a connection to {{ ydb-short-name }}" %}
+
+  ```go
+  package main
+
+  import (
+    "context"
+    "database/sql"
+    "os"
+
+    "github.com/ydb-platform/ydb-go-sdk/v3"
+  )
+
+  func main() {
+    ctx, cancel := context.WithCancel(context.Background())
+    defer cancel()
+    nativeDriver, err := ydb.Open(ctx,
+      os.Getenv("YDB_CONNECTION_STRING"),
+      ydb.WithAccessTokenCredentials(os.Getenv("YDB_TOKEN")),
+    )
+    if err != nil {
+      panic(err)
+    }
+    defer nativeDriver.Close(ctx)
+    connector, err := ydb.Connector(nativeDriver)
+    if err != nil {
+      panic(err)
+    }
+    db := sql.OpenDB(connector)
+    defer db.Close()
+    ...
+  }
+  ```
+
+  {% endcut %}
+
+  {% cut "If you use a connection string" %}
+
+  ```go
+  package main
+
+  import (
+    "context"
+    "database/sql"
+    "os"
+
+    _ "github.com/ydb-platform/ydb-go-sdk/v3"
+  )
+
+  func main() {
+    db, err := sql.Open("ydb", "grpcs://localohost:2135/local?token="+os.Getenv("YDB_TOKEN"))
+    if err != nil {
+      panic(err)
+    }
+    defer db.Close()
+    ...
+  }
+  ```
+
+  {% endcut %}
 
 
 - Java
 
-   ```java
-   public void work(String connectionString, String accessToken) {
-       AuthProvider authProvider = CloudAuthProvider.newAuthProvider(
-           IamTokenCredentialProvider.builder()
-               .token(accessToken)
-               .build()
-       );
+  ```java
+  public void work(String connectionString, String accessToken) {
+      AuthProvider authProvider = new TokenAuthProvider(accessToken);
 
-       GrpcTransport transport = GrpcTransport.forConnectionString(connectionString)
-               .withAuthProvider(authProvider)
-               .build();
+      GrpcTransport transport = GrpcTransport.forConnectionString(connectionString)
+              .withAuthProvider(authProvider)
+              .build();
 
-       TableClient tableClient = TableClient
-           .newClient(GrpcTableRpc.ownTransport(transport))
-           .build());
+      TableClient tableClient = TableClient.newClient(transport).build();
 
-       doWork(tableClient);
+      doWork(tableClient);
 
-       tableClient.close();
-   }
-   ```
+      tableClient.close();
+      transport.close();
+  }
+  ```
 
 - Node.js
 

+ 70 - 71
ydb/docs/en/core/reference/ydb-sdk/recipes/auth-anonymous.md

@@ -8,87 +8,86 @@ Below are examples of the code for anonymous authentication in different {{ ydb-
 
 - Go (native)
 
-   By default, anonymous authentication is used.
-   You can explicitly enable anonymous authentication as follows:
-   ```go
-   package main
-
-   import (
-     "context"
-
-     "github.com/ydb-platform/ydb-go-sdk/v3"
-   )
-
-   func main() {
-     ctx, cancel := context.WithCancel(context.Background())
-     defer cancel()
-     db, err := ydb.Open(ctx,
-       os.Getenv("YDB_CONNECTION_STRING"),
-       ydb.WithAnonymousCredentials(),
-     )
-     if err != nil {
-       panic(err)
-     }
-     defer db.Close(ctx)
-     ...
-   }
-   ```
+  By default, anonymous authentication is used.
+  You can explicitly enable anonymous authentication as follows:
+  ```go
+  package main
+
+  import (
+    "context"
+      
+    "github.com/ydb-platform/ydb-go-sdk/v3"
+  )
+
+  func main() {
+    ctx, cancel := context.WithCancel(context.Background())
+    defer cancel()
+    db, err := ydb.Open(ctx,
+      os.Getenv("YDB_CONNECTION_STRING"),
+      ydb.WithAnonymousCredentials(),
+    )
+    if err != nil {
+      panic(err)
+    }
+    defer db.Close(ctx)
+    ...
+  }
+  ```
 
 - Go (database/sql)
 
-   By default, anonymous authentication is used.
-   You can explicitly enable anonymous authentication as follows:
-   ```go
-   package main
-
-   import (
-     "context"
-     "database/sql"
-     "os"
-
-     "github.com/ydb-platform/ydb-go-sdk/v3"
-   )
-
-   func main() {
-     ctx, cancel := context.WithCancel(context.Background())
-     defer cancel()
-     nativeDriver, err := ydb.Open(ctx,
-       os.Getenv("YDB_CONNECTION_STRING"),
-       ydb.WithAnonymousCredentials(),
-     )
-     if err != nil {
-       panic(err)
-     }
-     defer nativeDriver.Close(ctx)
-     connector, err := ydb.Connector(nativeDriver)
-     if err != nil {
-       panic(err)
-     }
-     db := sql.OpenDB(connector)
-     defer db.Close()
-     ...
-   }
-   ```
+  By default, anonymous authentication is used.
+  You can explicitly enable anonymous authentication as follows:
+  ```go
+  package main
+
+  import (
+    "context"
+    "database/sql"
+    "os"
+    
+    "github.com/ydb-platform/ydb-go-sdk/v3"
+  )
+
+  func main() {
+    ctx, cancel := context.WithCancel(context.Background())
+    defer cancel()
+    nativeDriver, err := ydb.Open(ctx,
+      os.Getenv("YDB_CONNECTION_STRING"),
+      ydb.WithAnonymousCredentials(),
+    )
+    if err != nil {
+      panic(err)
+    }
+    defer nativeDriver.Close(ctx) 
+    connector, err := ydb.Connector(nativeDriver)
+    if err != nil {
+      panic(err)
+    }
+    db := sql.OpenDB(connector)
+    defer db.Close()
+    ...
+  }
+  ```
 
 - Java
 
-   ```java
-   public void work(String connectionString) {
-       AuthProvider authProvider = NopAuthProvider.INSTANCE;
+  ```java
+  public void work(String connectionString) {
+      AuthProvider authProvider = NopAuthProvider.INSTANCE;
 
-       GrpcTransport transport = GrpcTransport.forConnectionString(connectionString)
-               .withAuthProvider(authProvider)
-               .build();
+      GrpcTransport transport = GrpcTransport.forConnectionString(connectionString)
+              .withAuthProvider(authProvider)
+              .build());
 
-       TableClient tableClient = TableClient
-           .newClient(GrpcTableRpc.ownTransport(transport))
-           .build());
+      TableClient tableClient = TableClient.newClient(transport).build();
 
-       doWork(tableClient);
+      doWork(tableClient);
 
-       tableClient.close();
-   }
-   ```
+      tableClient.close();
+      transport.close();
+  }
+  ```
 
 - Node.js
 

+ 1 - 3
ydb/docs/en/core/reference/ydb-sdk/recipes/auth-env.md

@@ -28,7 +28,6 @@ Below are examples of the code for authentication using environment variables in
   import (
     "context"
     "os"
-
     environ "github.com/ydb-platform/ydb-go-sdk-auth-environ"
     "github.com/ydb-platform/ydb-go-sdk/v3"
   )
@@ -57,7 +56,6 @@ Below are examples of the code for authentication using environment variables in
     "context"
     "database/sql"
     "os"
-
     environ "github.com/ydb-platform/ydb-go-sdk-auth-environ"
     "github.com/ydb-platform/ydb-go-sdk/v3"
   )
@@ -104,6 +102,6 @@ Below are examples of the code for authentication using environment variables in
 
 - Node.js
 
-   {% include [auth-env](../../../../_includes/nodejs/auth-env.md) %}
+  {% include [auth-env](../../../../_includes/nodejs/auth-env.md) %}
 
 {% endlist %}

+ 59 - 59
ydb/docs/en/core/reference/ydb-sdk/recipes/auth-metadata.md

@@ -8,68 +8,68 @@ Below are examples of the code for authentication using environment variables in
 
 - Go (native)
 
-   ```go
-   package main
-
-   import (
-     "context"
-     "os"
-
-     "github.com/ydb-platform/ydb-go-sdk/v3"
-     yc "github.com/ydb-platform/ydb-go-yc"
-   )
-
-   func main() {
-     ctx, cancel := context.WithCancel(context.Background())
-     defer cancel()
-     db, err := ydb.Open(ctx,
-       os.Getenv("YDB_CONNECTION_STRING"),
-       yc.WithMetadataCredentials(ctx),
-       yc.WithInternalCA(), // append Yandex Cloud certificates
-     )
-     if err != nil {
-       panic(err)
-     }
-     defer db.Close(ctx)
-     ...
-   }
-   ```
+  ```go
+  package main
+
+  import (
+    "context"
+    "os"
+
+    "github.com/ydb-platform/ydb-go-sdk/v3"
+    yc "github.com/ydb-platform/ydb-go-yc"
+  )
+
+  func main() {
+    ctx, cancel := context.WithCancel(context.Background())
+    defer cancel()
+    db, err := ydb.Open(ctx,
+      os.Getenv("YDB_CONNECTION_STRING"),
+      yc.WithMetadataCredentials(ctx),
+      yc.WithInternalCA(), // append Yandex Cloud certificates
+    )
+    if err != nil {
+      panic(err)
+    }
+    defer db.Close(ctx) 
+    ...
+  }
+  ```
 
 - Go (database/sql)
 
-   ```go
-   package main
-
-   import (
-     "context"
-     "database/sql"
-     "os"
-
-     "github.com/ydb-platform/ydb-go-sdk/v3"
-     yc "github.com/ydb-platform/ydb-go-yc"
-   )
-
-   func main() {
-     ctx, cancel := context.WithCancel(context.Background())
-     defer cancel()
-     nativeDriver, err := ydb.Open(ctx,
-       os.Getenv("YDB_CONNECTION_STRING"),
-       yc.WithMetadataCredentials(ctx),
-       yc.WithInternalCA(), // append Yandex Cloud certificates
-     )
-     if err != nil {
-       panic(err)
-     }
-     defer nativeDriver.Close(ctx)
-     connector, err := ydb.Connector(nativeDriver)
-     if err != nil {
-       panic(err)
-     }
-     db := sql.OpenDB(connector)
-     defer db.Close()
-     ...
-   }
-   ```
+  ```go
+  package main
+
+  import (
+    "context"
+    "database/sql"
+    "os"
+
+    "github.com/ydb-platform/ydb-go-sdk/v3"
+    yc "github.com/ydb-platform/ydb-go-yc"
+  )
+
+  func main() {
+    ctx, cancel := context.WithCancel(context.Background())
+    defer cancel()
+    nativeDriver, err := ydb.Open(ctx,
+      os.Getenv("YDB_CONNECTION_STRING"),
+      yc.WithMetadataCredentials(ctx),
+      yc.WithInternalCA(), // append Yandex Cloud certificates
+    )
+    if err != nil {
+      panic(err)
+    }
+    defer nativeDriver.Close(ctx) 
+    connector, err := ydb.Connector(nativeDriver)
+    if err != nil {
+      panic(err)
+    }
+    db := sql.OpenDB(connector)
+    defer db.Close()
+    ...
+  }
+  ```
 
 - Java
 

+ 67 - 69
ydb/docs/en/core/reference/ydb-sdk/recipes/auth-service-account.md

@@ -8,72 +8,72 @@ Below are examples of the code for authentication using a service account file i
 
 - Go (native)
 
-   ```go
-   package main
-
-   import (
-     "context"
-     "os"
-
-     "github.com/ydb-platform/ydb-go-sdk/v3"
-     yc "github.com/ydb-platform/ydb-go-yc"
-   )
-
-   func main() {
-     ctx, cancel := context.WithCancel(context.Background())
-     defer cancel()
-     db, err := ydb.Open(ctx,
-       os.Getenv("YDB_CONNECTION_STRING"),
-       yc.WithServiceAccountKeyFileCredentials(
-         os.Getenv("YDB_SERVICE_ACCOUNT_KEY_FILE_CREDENTIALS"),
-       ),
-       yc.WithInternalCA(), // append Yandex Cloud certificates
-     )
-     if err != nil {
-       panic(err)
-     }
-     defer db.Close(ctx)
-     ...
-   }
-   ```
+  ```go
+  package main
+
+  import (
+    "context"
+    "os"
+
+    "github.com/ydb-platform/ydb-go-sdk/v3"
+    yc "github.com/ydb-platform/ydb-go-yc"
+  )
+
+  func main() {
+    ctx, cancel := context.WithCancel(context.Background())
+    defer cancel()
+    db, err := ydb.Open(ctx,
+      os.Getenv("YDB_CONNECTION_STRING"),
+      yc.WithServiceAccountKeyFileCredentials(
+        os.Getenv("YDB_SERVICE_ACCOUNT_KEY_FILE_CREDENTIALS"),
+      ),
+      yc.WithInternalCA(), // append Yandex Cloud certificates
+    )
+    if err != nil {
+      panic(err)
+    }
+    defer db.Close(ctx) 
+    ...
+  }
+  ```
 
 - Go (database/sql)
 
-   ```go
-   package main
-
-   import (
-     "context"
-     "database/sql"
-     "os"
-
-     "github.com/ydb-platform/ydb-go-sdk/v3"
-     yc "github.com/ydb-platform/ydb-go-yc"
-   )
-
-   func main() {
-     ctx, cancel := context.WithCancel(context.Background())
-     defer cancel()
-     nativeDriver, err := ydb.Open(ctx,
-       os.Getenv("YDB_CONNECTION_STRING"),
-       yc.WithServiceAccountKeyFileCredentials(
-         os.Getenv("YDB_SERVICE_ACCOUNT_KEY_FILE_CREDENTIALS"),
-       ),
-       yc.WithInternalCA(), // append Yandex Cloud certificates
-     )
-     if err != nil {
-       panic(err)
-     }
-     defer nativeDriver.Close(ctx)
-     connector, err := ydb.Connector(nativeDriver)
-     if err != nil {
-       panic(err)
-     }
-     db := sql.OpenDB(connector)
-     defer db.Close()
-     ...
-   }
-   ```
+  ```go
+  package main
+
+  import (
+    "context"
+    "database/sql"
+    "os"
+
+    "github.com/ydb-platform/ydb-go-sdk/v3"
+    yc "github.com/ydb-platform/ydb-go-yc"
+  )
+
+  func main() {
+    ctx, cancel := context.WithCancel(context.Background())
+    defer cancel()
+    nativeDriver, err := ydb.Open(ctx,
+      os.Getenv("YDB_CONNECTION_STRING"),
+      yc.WithServiceAccountKeyFileCredentials(
+        os.Getenv("YDB_SERVICE_ACCOUNT_KEY_FILE_CREDENTIALS"),
+      ),
+      yc.WithInternalCA(), // append Yandex Cloud certificates
+    )
+    if err != nil {
+      panic(err)
+    }
+    defer nativeDriver.Close(ctx) 
+    connector, err := ydb.Connector(nativeDriver)
+    if err != nil {
+      panic(err)
+    }
+    db := sql.OpenDB(connector)
+    defer db.Close()
+    ...
+  }
+  ```
 
 - Java
 
@@ -95,15 +95,13 @@ Below are examples of the code for authentication using a service account file i
   ```
 
 - Node.js
-  
-  ### Load service account data from file
 
-  {% include [auth-sa-file](../../../../_includes/nodejs/auth-sa-file.md) %}
+  Loading service account data from a file:
 
-  ### Load service account data from other source
+  {% include [auth-sa-file](../../../../_includes/nodejs/auth-sa-file.md) %}
 
-  When you need to load service account data from the outside, for example, from the secrets vault, this method is suitable:
+  Loading service account data from a third-party source (for example, a secret storage):
 
-  {% include [service-account-data](../../../../_includes/nodejs/auth-sa-data.md) %}
+  {% include [auth-sa-data](../../../../_includes/nodejs/auth-sa-data.md) %}
 
 {% endlist %}

+ 14 - 14
ydb/docs/en/core/reference/ydb-sdk/recipes/auth-static.md

@@ -8,37 +8,37 @@ Below are examples of the code for authentication based on a username and token
 
 - C++
 
-   ```c++
-   auto driverConfig = NYdb::TDriverConfig()
+  ```c++
+  auto driverConfig = NYdb::TDriverConfig()
      .SetEndpoint(endpoint)
      .SetDatabase(database)
      .SetCredentialsProviderFactory(NYdb::CreateLoginCredentialsProviderFactory({
-         .User = "user",
-         .Password = "password",
+        .User = "user",
+        .Password = "password",
      }));
 
-   NYdb::TDriver driver(driverConfig);
-   ```
+  NYdb::TDriver driver(driverConfig);
+  ```
 
 - Go (native)
 
-   You can pass the username and password in the connection string. For example:
+  You can pass the username and password in the connection string. For example:
 
-   ```shell
-   "grpcs://login:password@localohost:2135/local"
-   ```
+  ```shell
+  "grpcs://login:password@localohost:2135/local"
+  ```
 
-   You can also explicitly pass them using the `ydb.WithStaticCredentials` parameter:
+  You can also explicitly pass them using the `ydb.WithStaticCredentials` parameter:
 
   {% include [auth-static-with-native](../../../../_includes/go/auth-static-with-native.md) %}
 
 - Go (database/sql)
 
-   You can pass the username and password in the connection string. For example:
+  You can pass the username and password in the connection string. For example:
 
   {% include [auth-static-database-sql](../../../../_includes/go/auth-static-database-sql.md) %}
 
-   You can also explicitly pass the username and password at driver initialization via a connector using the `ydb.WithStaticCredentials` parameter:
+  You can also explicitly pass the username and password at driver initialization via a connector using the `ydb.WithStaticCredentials` parameter:
 
   {% include [auth-static-with-database-sql](../../../../_includes/go/auth-static-with-database-sql.md) %}
 
@@ -51,7 +51,7 @@ Below are examples of the code for authentication based on a username and token
       GrpcTransport transport = GrpcTransport.forConnectionString(connectionString)
               .withAuthProvider(authProvider)
               .build());
-      
+
       TableClient tableClient = TableClient.newClient(transport).build();
 
       doWork(tableClient);