I'm trying to understand why I get 401.
Steps taken:
created a elasticsearch.keystore
add the bootstrap.password successfully, with cat ~/.elk.secret | /opt/elasticsearch/bin/elasticsearch-keystore add -x 'bootstrap.password'
Since I've multiple instances running, I move it in the new conf directory
but now I get 401:
curl -X GET 'https://elastic:myFancyPass#myServer:9200/_cluster/health?pretty' -k
{
"error" : {
"root_cause" : [
{
"type" : "security_exception",
"reason" : "unable to authenticate user [elastic] for REST request [/_cluster/health?pretty]",
"header" : {
"WWW-Authenticate" : [
"Bearer realm=\"security\"",
"ApiKey",
"Basic realm=\"security\" charset=\"UTF-8\""
]
}
}
],
"type" : "security_exception",
"reason" : "unable to authenticate user [elastic] for REST request [/_cluster/health?pretty]",
"header" : {
"WWW-Authenticate" : [
"Bearer realm=\"security\"",
"ApiKey",
"Basic realm=\"security\" charset=\"UTF-8\""
]
}
},
"status" : 401
}
My understanding is that this error can be caused by two things:
wrong password (which I doubt it's my case)
wrong elasticsearch.file
How do I find which elasticsearch.keystore it is loading?
Running rootLogger.level = debug didn't help. I feel it would be great getting a confirmation such as /opt/elasticsearch/instance2/conf/elasticsearch.keystore
Related
I'm trying to install ElasticSearch on my mac.
I downloaded the tar from the official website and extract it.
Then I run the bin/elastic. After that I open https://localhost:9200/ and it displays the input field for username and password when I canceled it, this appears:
{
"error": {
"root_cause": [
{
"type": "security_exception",
"reason": "missing authentication credentials for REST request [/]",
"header": {
"WWW-Authenticate": [
"Basic realm=\"security\" charset=\"UTF-8\"",
"Bearer realm=\"security\"",
"ApiKey"
]
}
}
],
"type": "security_exception",
"reason": "missing authentication credentials for REST request [/]",
"header": {
"WWW-Authenticate": [
"Basic realm=\"security\" charset=\"UTF-8\"",
"Bearer realm=\"security\"",
"ApiKey"
]
}
},
"status": 401
}
I did not put a password or username and I look at the previous questions about that and no one is working for me.
What should I do?
Note: When I open http://localhost:9200/ it displays:
This page isn’t working localhost didn’t send any data.
ERR_EMPTY_RESPONSE
Tldr;
Seems like Elasticsearch create a password automatically.
You may want to set you own with
bin/elasticsearch-setup-passwords interactive
But in version 8.x and above it is deprecated.
You should be using
elasticsearch-setup-passwords interactive
I am trying to send email using gmail api service account from spring boot api.
GoogleCredentials credentials = ServiceAccountCredentials.fromStream(inputStream)
.createScoped(Collections.singletonList(StorageScopes.DEVSTORAGE_FULL_CONTROL));
credentials = credentials.createScoped(SCOPES);
credentials.refresh();
AccessToken refreshToken = credentials.refreshAccessToken();
OAuth2Credentials credentialsAccess = OAuth2Credentials.create(refreshToken);
LOGGER.info("refresh token {}", credentials.refreshAccessToken().getTokenValue());
LOGGER.info("refresh token {}", credentialsAccess.getAccessToken().getTokenValue());
HttpRequestInitializer requestInitializer = new HttpCredentialsAdapter(credentials);
Gmail service = new Gmail.Builder(new NetHttpTransport(), JacksonFactory.getDefaultInstance(),
requestInitializer).setApplicationName(APPLICATION_NAME).build();
Users a = service.users();
sendMessage(service, "me", mimeMessage);
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Precondition check failed.",
"reason" : "failedPrecondition"
} ],
"message" : "Precondition check failed.",
"status" : "FAILED_PRECONDITION"
}
I am learning the Java RestHighLevelClient but I can't find the answer to this question.
When you submit a REST request to something where a document is not found you will see something like this:
$ curl localhost:9200/customer/_doc/1?pretty
{
"error" : {
"root_cause" : [
{
"type" : "index_not_found_exception",
"reason" : "no such index [customer]",
"resource.type" : "index_expression",
"resource.id" : "customer",
"index_uuid" : "_na_",
"index" : "customer"
}
],
"type" : "index_not_found_exception",
"reason" : "no such index [customer]",
"resource.type" : "index_expression",
"resource.id" : "customer",
"index_uuid" : "_na_",
"index" : "customer"
},
"status" : 404
}
However in the Java client you code something like this:
GetRequest request = new GetRequest(INDEX, ROOT);
GetResponse response = null;
try {
response = client.get(request, RequestOptions.DEFAULT);
} catch (IOException ioe) {
// do something with the IOException
} catch (ElasticsearchException ese) {
// where is the response source?
}
So if the document is not found, you get the ElasticsearchException in which case the local variable response is null. So where do you get
the source document that was present at the low level? (Preferably as a Map).
You can get to the source of the response at the low level via the suppressesed exceptions in the ElasticsearchException.
Throwable[] suppressed = ese.getSuppressed();
if (suppressed.length > 0 && suppressed[0] instanceof ResponseException) {
ResponseException re = (ResponseException) suppressed[0];
Response response = re.getResponse();
}
I'm having a rough time figuring out how can I use this Endpoint but with HTTPS:
PUT twitter/_doc/1
{
"user" : "kimchy",
"post_date" : "2009-11-15T14:12:12",
"message" : "trying out Elasticsearch"
}
So changing to https doesn't work I don't get any response at all. I'm using X-Pack. Also, I didn't configure any special user.
Any hint?
I am trying to append_data to a Glympse ticket and I am getting a serialization error. I have tried many variation on the following request body and can not seem to make a successful call:
{
[
"n" : "destination",
"v" : {
"lat" : 43345678,
"lng" : -121456789
}
]
}
The timestamp field is required https://developer.glympse.com/docs/core/api/reference/tickets/id/append_data/post
[{"v":{"lng":-121456789,"lat":43345678},"t":1513869134948,"n":"destination"}]