Отчистка GET-запроса от мусора на ktor клиент

Делаю авторизацию через ВКонтакте.

После подтверждения авторизации пользователем ВКонтакте редиректит на примерно такую ссылку: http://localhost:8080/vk_callback?#access_token=123&expires_in=123&user_id=123&state=123

Символ '#' ломает парсинг GET-параметров библиотекой Ktor. Можно ли как то убрать этот символ?


Ответы (1 шт):

Автор решения: Eugene Krivenja

Правильно редиректит, все по OAuth 2.0 спецификации

For example, the authorization server redirects the user-agent by sending the following HTTP response (with extra line breaks for display purposes only):

 HTTP/1.1 302 Found
 Location: http://example.com/cb#access_token=2YotnFZFEjr1zCsicMWpAA
           &state=xyz&token_type=example&expires_in=3600

Developers should note that some user-agents do not support the inclusion of a fragment component in the HTTP "Location" response header field.

Т.е. вам надо правильно парсить запрос, не как GET параметры, а как фрагмент.
https://api.ktor.io/1.3.2/io.ktor.http/-url/fragment.html

→ Ссылка