Skip to content

Commit f9fbc9d

Browse files
committed
API-Key: Update elasticsearch-transport README
1 parent 421e7ea commit f9fbc9d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

elasticsearch-transport/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,26 @@ use the `transport_options` option:
128128
Elasticsearch::Client.new url: 'https://username:[email protected]:9200',
129129
transport_options: { ssl: { ca_file: '/path/to/cacert.pem' } }
130130

131+
You can also use [**API Key authentication**](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html):
132+
133+
``` ruby
134+
Elasticsearch::Client.new(
135+
host: host,
136+
transport_options: transport_options,
137+
api_key: credentials
138+
)
139+
```
140+
141+
Where credentials is either the base64 encoding of `id` and `api_key` joined by a colon or a hash with the `id` and `api_key`:
142+
143+
``` ruby
144+
Elasticsearch::Client.new(
145+
host: host,
146+
transport_options: transport_options,
147+
api_key: {id: 'my_id', api_key: 'my_api_key'}
148+
)
149+
```
150+
131151
### Logging
132152

133153
To log requests and responses to standard output with the default logger (an instance of Ruby's {::Logger} class),

0 commit comments

Comments
 (0)