-
Notifications
You must be signed in to change notification settings - Fork 34
Tiles 7500 key check #587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tiles 7500 key check #587
Conversation
| * производить поиск на карте: определять координаты геообъектов по их названиям и названия по координатам. | ||
|
|
||
| Чтобы начать использовать API карт нужно получить ключ, для этого напишите на почту [email protected], далее перейдите в раздел [Быстрый старт](http://api.2gis.ru/doc/maps/ru/quickstart/). | ||
| Чтобы начать использовать API карт нужно получить ключ, для этого напишите на почту [email protected], далее перейдите в раздел [Быстрый старт](https://docs.2gis.com/ru/maps/others/rasterjs/). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Поменял ссылку на новую доку это относится к задаче TILES-7316
| if (mapContainer) { | ||
| mapContainer.appendChild(errorMessage); | ||
| } else { | ||
| console.warn('Map container with id "map" not found.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно здесь и в src/DGGeoclicker/src/provider/CatalogApi.js (для console.error) исключения добавить, как это сделано тут
src/DGGeoclicker/demo/index.html
Outdated
| showBooklet: true, | ||
| showRouteSearch: true | ||
| showRouteSearch: true, | ||
| key: DG.config.key || 'Your API access key' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Этот кейс не совсем понял, тут мы только в опции геокликера ключ указываем?
| // } | ||
| // } | ||
|
|
||
| // TODO статус код может быть throttling или blocked |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
почему это в TODO осталось, что мешает сразу все доделать? Что нужно делать в случае throttling напрмиер
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут правильнее было бы оставить NOTE , тротл насколько я понял когда по ключу вдруг невероятное количество запросов начнет сыпаться, он тоже будет заблокирован и по хорошему тоже ошибка должна показаться с предложением обратится к нам
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Убрал совсем
| if (mapContainer) { | ||
| mapContainer.appendChild(errorMessage); | ||
| } else { | ||
| console.warn('Map container with id "map" not found.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
это ситуация невозможная же, если не контейнера, карта вообще не должна проинициализироваться
|
|
||
| var validator = new DG.ApiKeyValidator(apiKey); | ||
| validator.validate(function(response) { | ||
| // TODO пока на 400 ошибку (пользователь без ключа) не показываем ошибку (на релизе уже показываем) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Как ты планируешь потом начать показывать ошибку? Это же нужно будет всем обновить пакет. Есть вариант сейчас все предусмотреть?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Да, в таких случаях должен обновляться бэкенд, а не клиентский код. Я думаю, нужно договориться с бэком, чтобы сейчас любой запрос проходил валидацию (и не возвращал 4xx).
Тогда тут будет уже боевой код.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лена попросила так сделать с их стороны это норм поведение сейчас `Этим API не только растровые карты пользуются, контракт просто так не поменяешь.
Можете на своей стороне сделать обработку на время что 400 - это ок`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Предложение от Олега.
Вшить в код ключ на 2 месяца. Потом его инвалидировать.
| "key": "", | ||
|
|
||
| "keyServer": "https://keys.api.2gis.com/public/v1/keys/", | ||
| "keyServices": "/services/tiles-raster-api", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Потестил новый бэкэнд курлом. Вроде бы, работает корректно.
| var validator = new DG.ApiKeyValidator(apiKey); | ||
| validator.validate(function(response) { | ||
|
|
||
| if (response.meta.code === 400 || !response.result.service.is_active || !response.result.is_active || response.result.service.status.code !== 'ok') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А напомни, почему бишь мы проверяем именно 400 код, а не 403?
Такой ответ дает наш бэк?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Если пустой ключ отправить то он возвращает 400 и собщение о невалидном формате если я не путаю
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.

У нас была проблема при которой мы точно не могли определить из-за чего произошла ошибка на тайлах, и показывали сообщение о проблеме с ключом на все, сейчас мы стали использовать keyserver и понимаем статус ключа и только если у пользователя проблемы с ключом показываем ошибку.
Посмотреть код, проверить работу с разными ключами (валидный,не валидный, пустой)
Посмотреть тесты