File tree Expand file tree Collapse file tree 2 files changed +40
-2
lines changed
Expand file tree Collapse file tree 2 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,38 @@ YDB supports the following authentication methods:
3434- Metadata URL
3535- Anonymous
3636
37+ ## Access token
38+
39+ Use your access token:
40+
41+ ``` php
42+ <?php
43+
44+ use YdbPlatform\Ydb\Ydb;
45+
46+ $config = [
47+
48+ // Database path
49+ 'database' => '/ru-central1/b1glxxxxxxxxxxxxxxxx/etn0xxxxxxxxxxxxxxxx',
50+
51+ // Database endpoint
52+ 'endpoint' => 'ydb.serverless.yandexcloud.net:2135',
53+
54+ // Auto discovery (dedicated server only)
55+ 'discovery' => false,
56+
57+ // IAM config
58+ 'iam_config' => [
59+ 'root_cert_file' => './CA.pem', // Root CA file (dedicated server only!)
60+
61+ // Access token authentication
62+ 'access_token' => 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
63+ ],
64+ ];
65+
66+ $ydb = new Ydb($config);
67+ ```
68+
3769## OAuth token
3870
3971You should obtain [ a new OAuth token] ( https://cloud.yandex.com/docs/iam/concepts/authorization/oauth-token ) .
@@ -67,7 +99,6 @@ $config = [
6799];
68100
69101$ydb = new Ydb($config);
70-
71102```
72103
73104## JWT + private key
Original file line number Diff line number Diff line change @@ -73,7 +73,10 @@ public function config($key, $default = null)
7373 */
7474 public function token ($ force = false )
7575 {
76- if ($ force || !($ token = $ this ->loadToken ()))
76+ if ($ token = $ this ->config ('access_token ' )){
77+ return $ token ;
78+ }
79+ else if ($ force || !($ token = $ this ->loadToken ()))
7780 {
7881 $ token = $ this ->newToken ();
7982 }
@@ -184,6 +187,7 @@ protected function parseConfig(array $config)
184187 $ stringParams = [
185188 'temp_dir ' ,
186189 'root_cert_file ' ,
190+ 'access_token ' ,
187191 'oauth_token ' ,
188192 'key_id ' ,
189193 'service_account_id ' ,
@@ -272,6 +276,9 @@ protected function initConfig()
272276 throw new Exception ('Private key [ ' . $ privateKeyFile . '] is missing. ' );
273277 }
274278 }
279+ else if ($ this ->config ('access_token ' )){
280+ $ this ->logger ()->info ('YDB: Authentication method: Access token ' );
281+ }
275282 else if ($ this ->config ('oauth_token ' ))
276283 {
277284 $ this ->logger ()->info ('YDB: Authentication method: OAuth token ' );
You can’t perform that action at this time.
0 commit comments